Game Development Community

Dynamically creating paths - RESOLVED

by Charlie Mauck · in Torque Game Builder · 01/31/2008 (1:03 am) · 2 replies

I'm guessing there's an obvious answer to this, but I've dug around the TDN extensivley and I can't find any tutorials on dynamic t2dPath creation, and the reference doesn't seem to be telling me what else I need to do.

Basic plan: to make an object move along a dynamically created path.

What I'm doing: attempting to test this out by executing the needed commands right from the console.

What I've got: a basic t2dStaticSprite sitting on the screen.

I execute the following:

$testPath2 = new t2dPath()
$testPath2.setPathType = "LINEAR"
$testPath2.addNode( "0 20" )
$testPath2.addNode( "48 20" )
$testPath2.attachObject( , 45, 1, 0, 1, "WRAP", 2, 1 )

Because I set the %sendToStart to true, the object correctly jumps to the start node (0, 20), but then nothing else happens. I can reverse the start and end nodes, and the object will jump to the end node instead. I can successfully query (with the appropriate 'get' methods) every attribute to verify that it's set. I've gone through and explicitly set each attribute induvidually as well. Nothing seems to get the object to move along the path.

What do I do to make the object move down the path? Obviously attching it to the path and setting it's speed and direction are not enough. What am I missing here?

My primary reference source for this:
http://tdn.garagegames.com/wiki/TGB/Reference:_t2dPath

Thanks!

#1
02/01/2008 (12:24 am)
Yup, it was as simple as I expected, although it sure took me a bit of messing around to figure it out.

Basically, although I had dynamically created the path, it was not getting processed because it was not attached to the current scene. Adding the one line: $testPath2.addToScene( .getSceneGraph() ) caused the path to process fine.

Final console line entries:

$testPath2 = new t2dPath()
$testPath2.addToScene( .getSceneGraph() )
$testPath2.setPathType = "LINEAR"
$testPath2.addNode( "0 20" )
$testPath2.addNode( "48 20" )
$testPath2.addNode( "48 0" )
$testPath2.attachObject( , 45, 1, 0, 1, "WRAP", 2, 1 )
#2
02/01/2008 (6:11 am)
Charlie,
I used always to forget to attach it to the current scene. When I create objects, I now do it like this:

$testPath2 = new t2dPath(){scenegraph = <sprite_name>.scenegraph};