T2dPath Node Allocation
by Adam Griffiths · in Torque Game Builder · 04/23/2008 (5:09 am) · 2 replies
Hello All.
I've recently been playing around with the t2dPath objects trying to get an enemy to follow certain paths using the t2d.attachObject method
No problems with attaching, it all works okay. My problem is that however I create the path in the builder, it never turns out like I created.
For example, I create a Node at North, then South, then East, then West.
When the enemy is spawned and then gets to its target position, it goes to South 1st, then clockwise around settling on East.
What I was wondering is if anyone knew how the t2dPath's allocated the nodes? When I do an echo statement with t2dPath.getNode the t2dPath says that Node 0 is South, 1 is West, 2 is North, 3 is East.
There is an easy work around of course by testing, finding out which one is the start node and then going back into the builder and moving the nodes but this shouldn't be necessary. Surely the way you click and add the nodes within the builder should determine which nodes are the start and end.
I've also tried using the getStartNode function but this doesn't seem to work when an echo statement is used within script but within the console it does so I can't set my start and end nodes in script.
The other thing I've noticed is if the path is Bezier or Catmull then the object jumps to the start node even if the attachObject function specifies it to move their instead.
The TDN is also bizarrely very bare when trying to find out anything about the t2dPath object. All there is is a brief glossary and description of methods yet nothing on nodes.
Could anyone shed any light?
I've recently been playing around with the t2dPath objects trying to get an enemy to follow certain paths using the t2d.attachObject method
No problems with attaching, it all works okay. My problem is that however I create the path in the builder, it never turns out like I created.
For example, I create a Node at North, then South, then East, then West.
When the enemy is spawned and then gets to its target position, it goes to South 1st, then clockwise around settling on East.
What I was wondering is if anyone knew how the t2dPath's allocated the nodes? When I do an echo statement with t2dPath.getNode the t2dPath says that Node 0 is South, 1 is West, 2 is North, 3 is East.
There is an easy work around of course by testing, finding out which one is the start node and then going back into the builder and moving the nodes but this shouldn't be necessary. Surely the way you click and add the nodes within the builder should determine which nodes are the start and end.
I've also tried using the getStartNode function but this doesn't seem to work when an echo statement is used within script but within the console it does so I can't set my start and end nodes in script.
The other thing I've noticed is if the path is Bezier or Catmull then the object jumps to the start node even if the attachObject function specifies it to move their instead.
The TDN is also bizarrely very bare when trying to find out anything about the t2dPath object. All there is is a brief glossary and description of methods yet nothing on nodes.
Could anyone shed any light?
#2
The main problem is still apparent though therefore rendering the paths useless at present. I've found that when the path is anything other than Linear, an object will instantly jump to the first node rather than walking there.
I'm not changing the path function at all as I've created a behavior which just reads in whichever path you want to use. It then sets the object to travel along it using t2dPath::attachObject, with the end parameter (%sendToStart) being set to false so that it moves there rather than instantly transporting there.
If the path is Linear, the object moves to the first node and then carries on through the path from there.
If its Bezier, object jumps to first node and then carries on through the path.
If its Catmull, object jumps to first node and then carries on through the path.
Does anybody else have any knowledge of this ever happening to them? Or has anyone looked into paths in great detail who could help clear up things? :D
04/30/2008 (6:20 am)
Hi Dmitriy, Yes thank you it did help a little with the allocation of nodes properly meaning that the paths are nicely created now.The main problem is still apparent though therefore rendering the paths useless at present. I've found that when the path is anything other than Linear, an object will instantly jump to the first node rather than walking there.
I'm not changing the path function at all as I've created a behavior which just reads in whichever path you want to use. It then sets the object to travel along it using t2dPath::attachObject, with the end parameter (%sendToStart) being set to false so that it moves there rather than instantly transporting there.
If the path is Linear, the object moves to the first node and then carries on through the path from there.
If its Bezier, object jumps to first node and then carries on through the path.
If its Catmull, object jumps to first node and then carries on through the path.
Does anybody else have any knowledge of this ever happening to them? Or has anyone looked into paths in great detail who could help clear up things? :D
Torque Owner Dmitriy Stukalov
May be the alternative path editor will help you. Try my Path Editor for TGB. It totally free.