mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 07:34:45 +00:00
Updates AIPlayer script class to account for looping paths and slows the aiplayer down on the lastnode if it's not a looping path.
This commit is contained in:
parent
3e3006024c
commit
140892e032
1 changed files with 18 additions and 13 deletions
|
|
@ -140,26 +140,31 @@ function AIPlayer::followPath(%this,%path,%node)
|
||||||
|
|
||||||
function AIPlayer::moveToNextNode(%this)
|
function AIPlayer::moveToNextNode(%this)
|
||||||
{
|
{
|
||||||
if (%this.targetNode < 0 || %this.currentNode < %this.targetNode)
|
%pathNodeCount=%this.path.getCount();
|
||||||
{
|
%slowdown=0;
|
||||||
if (%this.currentNode < %this.path.getCount() - 1)
|
|
||||||
%this.moveToNode(%this.currentNode + 1);
|
%targetNode=%this.currentNode + 1;
|
||||||
else
|
|
||||||
%this.moveToNode(0);
|
if (%this.path.isLooping) {
|
||||||
|
%targetNode %= %pathNodeCount;
|
||||||
|
} else {
|
||||||
|
if (%targetNode >= %pathNodeCount-1) {
|
||||||
|
%targetNode=%pathNodeCount-1;
|
||||||
|
|
||||||
|
if (%currentNode < %targetNode)
|
||||||
|
%slowdown=1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
if (%this.currentNode == 0)
|
%this.moveToNode(%targetNode, %slowdown);
|
||||||
%this.moveToNode(%this.path.getCount() - 1);
|
|
||||||
else
|
|
||||||
%this.moveToNode(%this.currentNode - 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function AIPlayer::moveToNode(%this,%index)
|
function AIPlayer::moveToNode(%this,%index,%slowdown)
|
||||||
{
|
{
|
||||||
// Move to the given path node index
|
// Move to the given path node index
|
||||||
%this.currentNode = %index;
|
%this.currentNode = %index;
|
||||||
%node = %this.path.getObject(%index);
|
%node = %this.path.getObject(%index);
|
||||||
%this.setMoveDestination(%node.getTransform());
|
%this.setMoveDestination(%node.getTransform(),%slowdown);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue