Game Development Community

Better understanding coding paths

by rennie moffat · in Torque Game Builder · 03/23/2010 (6:46 am) · 3 replies

I am building a path however the documentation on it seems quite thin. Currently I need an object to choose a direction when he hits a node. So picture a car reaching an intersection, the car must then choose left, right or straight ahead. If anyone could help me with this I would appreciate it. As I say it is not so much the choosing of a random direction but simply learning the ins and outs of paths.


Thanks,
Ren

About the author

My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.


#1
06/30/2010 (9:48 pm)
Hey Rennie, I am currently having some issues with paths. It's a well known fact that the pathing system doesn't work as well as it should, but maybe I can shed some light on things. Do you have a code snippet to better explain what you need?
#2
07/01/2010 (2:20 am)
I gave up on paths probably right after this post (march). I created my own system of sceneObjects as nodes and simply instructing my object, which needs to move on a "path" to move from one node to the next. It works. If you want more detail I can give it.


#3
07/01/2010 (8:42 am)
Here is my code for the Wraith alien in sector 6. I was having a bunch a problems until I generated the path object in script. I left behind the prototype path in the editor because I couldn't figure out how to create a new node from scratch.

function SectorLevel::initWraithPath(%this,%alien)
{

   %wraithPath = new t2dPath() {  
      scenegraph = sceneWindow2D.getSceneGraph();  
      pathType = "CATMULL";  
   };  
   for (%i = 0; %i < wPath.getNodeCount(); %i++)  
      %wraithPath.addNode(wPath.getnode(%i));  
         
   %wraithPath.Position="0 0";
   %wraithPath.attachObject(%alien, %alien.speed, true, 0, 2, "WRAP", true);
   %wraithPath.setLoops(%alien,-1);
   %wraithPath.setOrient(%alien, false); 
   %rnd=getRandom(0,1);
   %wraithPath.setMoveForward(%alien, %rnd); 
   %wraithPath.size="175 175";
   %alien.path = %wraithPath;
}