AI Player reverse direction??
by Jeff Murray · in Technical Issues · 02/16/2007 (10:28 am) · 1 replies
Hey guys,
I'm trying to figure out how I can reverse the direction of an AIPlayer along a path.
It's kind of confusing, because I'm not sure I understand the relationships between currentNode and targetNode in the AIPlayer.cs script ... and it seems to 'lose scope' or something between functions.
Basically, my AI player moves around the path and his speed will vary ... so, in my 'think' function in AIPlayer I have:
as you can see, I've been trying to get the value of %this.currentNode and %this.targetNode but it always returns nothing.
The idea here (above) is that when $speed drops below zero, it will change the current node to the last node, then do a 'movetoNode' to tell the player to head in that direction. In effect, reversing the players direction along the path.
Just as a side note ... I know I shouldn't be hacking the speed into a global, but for the purposes of 'getting it going' that's just how I hacked it :p
Anyone got any ideas on how to tackle this one, without engine changes? (I have to avoid any engine modifications for this project)
Thanks, guys!! :)
I'm trying to figure out how I can reverse the direction of an AIPlayer along a path.
It's kind of confusing, because I'm not sure I understand the relationships between currentNode and targetNode in the AIPlayer.cs script ... and it seems to 'lose scope' or something between functions.
Basically, my AI player moves around the path and his speed will vary ... so, in my 'think' function in AIPlayer I have:
if ($speed<0){
%this.player.setMoveSpeed(-$speed);
//warn("SPEED IS "@$speed);
//warn("CURRENTNODE IS "@%this.currentNode);
//warn("TARGETNODE IS "@%this.targetNode);
// Now check that we are heading towards a previous node on the path
if (%this.currentNode < %this.targetNode){
%this.targetNode=%this.targetNode-1;
%this.currentNode=%this.currentNode-1;
if (%this.currentNode < 0){
%this.targetNode = %this.path.getCount() - 1;
}
%this.moveToNode(%this.targetNode);
}
} else{
%this.player.setMoveSpeed($speed);
}as you can see, I've been trying to get the value of %this.currentNode and %this.targetNode but it always returns nothing.
The idea here (above) is that when $speed drops below zero, it will change the current node to the last node, then do a 'movetoNode' to tell the player to head in that direction. In effect, reversing the players direction along the path.
Just as a side note ... I know I shouldn't be hacking the speed into a global, but for the purposes of 'getting it going' that's just how I hacked it :p
Anyone got any ideas on how to tackle this one, without engine changes? (I have to avoid any engine modifications for this project)
Thanks, guys!! :)
Torque Owner Jeff Murray
Default Studio Name