Game Development Community

Behavior for bots

by Dennis Mathews · in Torque Game Engine · 02/22/2002 (9:22 am) · 3 replies

I am new to the Torque engine and have been reading several threads about bot movement. I am still little lost when it comes to one thing. I have my bots loading from script and I want them to detect when I get close to them. I am having trouble finding a place to put a function to check for the position of other objects every frame.

#1
02/22/2002 (9:43 am)
what i did was create an ai.cs file, and in there wrote all of my bot stuff. If you do something like this, make sure you exec it in game.cs (or at least, someplace)
ryan
#2
02/22/2002 (10:15 am)
Ok I have made my ai script but is there a function I should be overiding that gets called every time and not just at start up.
#3
02/22/2002 (1:56 pm)
You could use "schedule(time, object, function)" like this:
function scheduledScanning(%this)
{
    echo("Schedule running!");
    $scanSchedule = schedule(500, 0, "scheduledScanning");
}

and start it in aiPlayer.cs, e.g. in onMove():

function AIPlayer::onMove(%this) {
    scheduledScanning(%this);
    echo( "On my way, master!");
}

and then stop it, if you want:
function AIPlayer::onReachDestination() {
    cancel($scanSchedule);
    echo( "I'm tired, master..." );
}

Or you could write your own callback routines, etc...