Problems with AI
by Bristow · in Torque Game Engine · 06/03/2006 (5:10 pm) · 3 replies
Ok so here's my code:
function AIPlayer::searchforplayer(%this)
{
%distance = VectorLen(VectorSub(%this.getTransform(), Cecil.getTransform() ) );
if (%distance <= 20)
{
%this.setMoveDestination(Cecil.getTransform());
echo("close enough");
schedule(1000,0,%this.searchforplayer());
}
else
{
echo("not close enough");
schedule(100,0,%this.searchforplayer());
}
}
All I want it to do is if Cecil (just what I named the player) is within 20 feet run towards him, otherwise basically wait till Cecil is within 20 feet
passing in the name of the AI player seems to work fine for everyhing but schedule, where it crashes
Basically I'm just trying to make a function where if I had more than one enemy in game at a time they could both use this function. The only thing that seems not to work is how I'm using the schedule function, is that the problem?
function AIPlayer::searchforplayer(%this)
{
%distance = VectorLen(VectorSub(%this.getTransform(), Cecil.getTransform() ) );
if (%distance <= 20)
{
%this.setMoveDestination(Cecil.getTransform());
echo("close enough");
schedule(1000,0,%this.searchforplayer());
}
else
{
echo("not close enough");
schedule(100,0,%this.searchforplayer());
}
}
All I want it to do is if Cecil (just what I named the player) is within 20 feet run towards him, otherwise basically wait till Cecil is within 20 feet
passing in the name of the AI player seems to work fine for everyhing but schedule, where it crashes
Basically I'm just trying to make a function where if I had more than one enemy in game at a time they could both use this function. The only thing that seems not to work is how I'm using the schedule function, is that the problem?
About the author
Torque Owner Brian Hill