My path hiccups
by baylor wetzel · in General Discussion · 04/03/2007 (10:05 pm) · 0 replies
Whiel trying to make a board game, i dynamically generated a path in script. It worked really, really well as long as the object kept moving around the path. But when i set it to just move once, i had problems
i *think* the way to do this is to set the number of loops to 1. Here's the code:
i also tried this using the per-field commands (setEndNode, setLoops, etc.)
It looks like things are going to work - my object moves from start node to end node. Then 2-5 seconds later (at random), the object backs up a node and then tries it again. And again. And again. Totally at random. It looks like my object is hiccuping. Occassionally TGB dies from a buffer overflow heart attack
This is on a near-blank test level. There is no collision. Other than the object on the path, nothing is moving. The console shows nothing
i can't find a lot of documentation on this. i did find mention of an event called onUpdatePath but it never gets called for my object, so my debug info there doesn't help me
Anyone have any ideas?
Full code:
i *think* the way to do this is to set the number of loops to 1. Here's the code:
//--- Args: obj, speed, isForward, startNode, endNode, followMode, loops mainPath.attachObject(ship, 30, 1, %start, %end, "WRAP", 1);
i also tried this using the per-field commands (setEndNode, setLoops, etc.)
It looks like things are going to work - my object moves from start node to end node. Then 2-5 seconds later (at random), the object backs up a node and then tries it again. And again. And again. Totally at random. It looks like my object is hiccuping. Occassionally TGB dies from a buffer overflow heart attack
This is on a near-blank test level. There is no collision. Other than the object on the path, nothing is moving. The console shows nothing
i can't find a lot of documentation on this. i did find mention of an event called onUpdatePath but it never gets called for my object, so my debug info there doesn't help me
Anyone have any ideas?
Full code:
function initVariables()
{
if (isObject(mainPath))
{
mainPath.clear();
mainPath.safeDelete();
}
}
function buildPath()
{
if (isObject(mainPath)) error("how 'come mainPath already exists?");
new t2dPath(mainPath) {
//--- Do i need to add this to the scenegraph? Yes
scenegraph = sceneWindow2D.getSceneGraph();
pathType = "CATMULL";
};
mainPath.addNode(startingBlock.getPosition(), 0);
for (%i=1; %i < $numberOfTiles; %i++)
{
%tile = $tiles[%i];
mainPath.addNode(%tile.getPosition(), %i);
}
mainPath.setDebugOn(1);
}
function moveShip(%start, %end)
{
//--- obj, speed, isForward, startNode, endNode, followMode, loops, sendToStart
//--- FollowMode = wrap, reverse, restart
/* mainPath.attachObject(ship, 0);
mainPath.setStartNode(ship, %start);
mainPath.setEndNode(ship, %end);
mainPath.setOrient(ship, false);
mainPath.setSpeed(ship, 30);
// mainPath.setMoveForward(ship, true);
mainPath.setLoops(ship, 1);
*/
mainPath.attachObject(ship, 30, 1, %start, %end, "WRAP", 1);
//--- Hickups on last node :(
echo("loops = " @ mainPath.getLoops(ship));
echo("end node = " @ mainPath.getEndNode(ship));
}About the author