AI Scripting - Controlling precision of waypoints / markers?
by Lloyd [Bleeptech] Godsey · in Torque Game Engine · 01/26/2004 (5:09 pm) · 4 replies
Can I control the precision of the pathfollowing via script? I.E. with "scale"
new Marker() {
position = "-159.967 955.497 198";
rotation = "1 0 0 0";
scale = "4 4 4"; // Was "1 1 1" should increase wander % around marker
seqNum = "1";
type = "Normal";
msToNext = "1000";
smoothingType = "Spline";
};
Or will It need a recompile?
EDIT:
Never mind.. "scale didn't work at all. I'm now rewriting (or trying to)
function AIPlayer::moveToNode(%this,%index)
to be
function AIPlayer::moveNearNode(%this,%index)
new Marker() {
position = "-159.967 955.497 198";
rotation = "1 0 0 0";
scale = "4 4 4"; // Was "1 1 1" should increase wander % around marker
seqNum = "1";
type = "Normal";
msToNext = "1000";
smoothingType = "Spline";
};
Or will It need a recompile?
EDIT:
Never mind.. "scale didn't work at all. I'm now rewriting (or trying to)
function AIPlayer::moveToNode(%this,%index)
to be
function AIPlayer::moveNearNode(%this,%index)
#2
01/26/2004 (10:24 pm)
What about add or substract a random number from the x and/or y coordinates of the position?
#3
01/27/2004 (11:02 am)
This is what I did to get a group of bots to run near the marker. :)//-----------------------------------------------------------------------------
function AIPlayer::moveNearNode(%this,%index)
{
// Move near the given path node index
%this.currentNode = %index;
%node = %this.path.getObject(%index);
%node_pos = %node.getTransform();
%x = getWord(%node_pos, 0);
%y = getWord(%node_pos, 1);
%z = getWord(%node_pos, 2);
%rnd1=getrandom(20);
%rnd2=getrandom(20);
%rnd3=getrandom(20);
if(%rnd1<10){%rnd01=%x+getrandom(5);}
else{%rnd01=%x-getrandom(5);}
if(%rnd2<10){%rnd02=%y+getrandom(5);}
else{%rnd02=%y-getrandom(5);}
if(%rnd3<10){%rnd03=%z+getrandom(5);}
else{%rnd03=%z-getrandom(5);}
%dest = %rnd01 SPC %rnd02 SPC %rnd03;
%this.setMoveDestination(%dest);
}
//-----------------------------------------------------------------------------
#4
I believe you could further optimize your function:
I believe the getRandom() script function supports a min and max range. This would save you some function calls and branching.
Note: I've written this without the TGE in front of me nor have I tested it.
- LightWave Dave
01/28/2004 (7:31 am)
Greetings!I believe you could further optimize your function:
//-----------------------------------------------------------------------------
function AIPlayer::moveNearNode(%this,%index)
{
// Move near the given path node index
%this.currentNode = %index;
%node = %this.path.getObject(%index);
%node_pos = %node.getTransform();
%x = getWord(%node_pos, 0) + getRandom(-5,5);
%y = getWord(%node_pos, 1) + getRandom(-5,5);
%z = getWord(%node_pos, 2) + getRandom(-5,5);
%dest = %x SPC %y SPC %z;
%this.setMoveDestination(%dest);}
//-----------------------------------------------------------------------------I believe the getRandom() script function supports a min and max range. This would save you some function calls and branching.
Note: I've written this without the TGE in front of me nor have I tested it.
- LightWave Dave
Associate Kyle Carter