How to get position of a path node? Sounds easy but...
by Lee Latham · in Torque Game Engine · 02/08/2007 (2:03 am) · 4 replies
If you do %obj.currentNode.getPosition(), You'll get something like:
starter.fps/server/scripts/aiPlayer.cs (485): Unable to find object: '1' attempting to call function 'getPosition'
because %obj.currentNode yields the current node in the "node order", from 0 to whatever, and not the internal name (such as object #1352).
I'm trying to influence what the ai player does when he gets near a node by measuring the distance between him and the node. I can get his position fine, but...any ideas?
starter.fps/server/scripts/aiPlayer.cs (485): Unable to find object: '1' attempting to call function 'getPosition'
because %obj.currentNode yields the current node in the "node order", from 0 to whatever, and not the internal name (such as object #1352).
I'm trying to influence what the ai player does when he gets near a node by measuring the distance between him and the node. I can get his position fine, but...any ideas?
#2
Thus, I'm thinking to do a periodic distance test from the nodes, which would therefore require me to get the X Y Z location of the node.
02/08/2007 (11:06 am)
Sorry, I think I wasn't clear. I'm looking to "do stuff" at a certain distance from the node (in addition to the path following, which is working fine).Thus, I'm thinking to do a periodic distance test from the nodes, which would therefore require me to get the X Y Z location of the node.
#3
you will use:
and %pos will be the position of the current node
02/08/2007 (11:11 am)
Its done in the above methodyou will use:
%obj.currentNode = %index; %node = %obj.path.getObject(%index); %pos = %node.getPosition();
and %pos will be the position of the current node
Torque 3D Owner Vincent D
function AIWheeledVehicle::moveToNode( %this, %index ) { // Move to the given path node index %this.currentNode = %index; %node = %this.path.getObject(%index); %this.setMoveDestination( %node.getTransform(), %index == %this.targetNode ); }thats how its done