AI Player problem
by James Jacoby · in Torque Game Engine · 04/29/2004 (2:12 pm) · 1 replies
I'm in the process of creating an NPC that follows the player around the world. However, I've hit a snag. The NPC won't start moving unless I manually call setMoveSpeed(x) from the console. Here is part of my code:
function AIPlayer::moveTowardPlayer(%this)
{
%aPlayer = %this.getFirstPlayer();
//if( VectorDist( %this.getTransform(), %aPlayer.getTransform() ) > 10 )
echo( "Searching for new direction" );
%this.aimAt( %aPlayer );
%this.setMoveDestination( %aPlayer.getTransform(), false );
%this.setMoveSpeed( 0.20 );
echo( "Moving toward: (" @ %this.getMoveDestination() @ ")" );
}
When the mission starts, the NPC is standing there looking at me and he will turn to look at me when I walk around. Therefore, the aimAt() part must be working.
In the console is says:
I'm here and my ID is: 1246
Searching for new direction
Aim: 1245
Moving toward: (23.106300 -410.856995 166.035995)
If I type 1246.setMoveSpeed( 1 );
He'll start following me around the map.
I even tried putting setMoveSpeed() calls in onAdd, onStop etc
Please help
-Thanks!
function AIPlayer::moveTowardPlayer(%this)
{
%aPlayer = %this.getFirstPlayer();
//if( VectorDist( %this.getTransform(), %aPlayer.getTransform() ) > 10 )
echo( "Searching for new direction" );
%this.aimAt( %aPlayer );
%this.setMoveDestination( %aPlayer.getTransform(), false );
%this.setMoveSpeed( 0.20 );
echo( "Moving toward: (" @ %this.getMoveDestination() @ ")" );
}
When the mission starts, the NPC is standing there looking at me and he will turn to look at me when I walk around. Therefore, the aimAt() part must be working.
In the console is says:
I'm here and my ID is: 1246
Searching for new direction
Aim: 1245
Moving toward: (23.106300 -410.856995 166.035995)
If I type 1246.setMoveSpeed( 1 );
He'll start following me around the map.
I even tried putting setMoveSpeed() calls in onAdd, onStop etc
Please help
-Thanks!
About the author
Associate Anthony Rosenbaum
Im not certain if it is ai player or player do a this.dump() to get a readout on the bot.