Game Development Community

Controling AI's Movment

by Caleb · in Technical Issues · 09/24/2006 (3:40 pm) · 6 replies

I have an AI character that will fire a crossbow when I get within 44 feet. Now what I want him to do is, get closer when he is about 55 feet away and run backwards when he is about 10 to 20 feet away from the player.

I was just wondering if there is commands to access the forward and backward movments?

#1
09/24/2006 (5:12 pm)
Well.. there's aiplayer.setmovedestination(%vec)
vectordist(%vec1, %vec2) would be used to see if he's too close or too far.
#2
09/24/2006 (5:58 pm)
I know about these functions, but its not what I'm looking for.

I think I'll look at the player movement code tomorrow to see were all this stuff is getting called
Thanks!
#3
09/24/2006 (9:00 pm)
Well.... if you want him to move backwards from something.. you could always just set the player as the target before setting the desitnation... that will cause the bot to face the player... and move backwards.
#4
09/25/2006 (8:08 am)
What are you looking for then? Where to put your scripts?
#5
09/25/2006 (8:28 am)
Your problem seems to be ideal for a Reactive System.

There are also simple Steering Behaviors that will try to keep your AI agent at the same distance from a moving object.
#6
09/27/2006 (4:28 pm)
Thanks for your help everybody.

I'll most likely do this:

....................................
//In a function
%vecX = getRandom(-50, 50);
%vecY = getRandom(-50, 50);
BadGuy.setMoveDestination(VectorAdd(myGuy.getPosition(), "%vecX vecY 0"));
....................................

If I schedule this every 4 or 5 seconds whenever my AI is under a certain distance, it will look like he is trying run away.