-
how to make AI RUN away
i need help to make th AI run away from character!!
help
-
Script kiddie
What viewpoint? Are there obstacles, walls, places that it should specifically be running to? Is it trying to avoid a projectile attack or a close-range attack? Finally, are you trying to make it actually competent at avoiding whatever it's running away from (strafing around bullets, etc), or are you trying to make it look like a natural "panicked crowd" effect? All of this is relevant.
-
by letting them move in the opposite direction of the player towards the AI bots
simple question simple answer
-
can you give me only a top view AI please only
-
Senior Member
Originally Posted by askentoyou
can you give me only a top view AI please only
here
-
obviously realMakc thinks you still are way to vague,- so do I. What you provided so far is nothing to work with
just post a example of what you have so far, because even top view it could be anything.
a general approach could be:
PHP Code:
function moveBot(nr){
dir_x = player.x - bot[nr].x;
dir_y = player.y - bot[nr].y;
dir_x/= Math.abs( dir_x);
dir_y/= Math.abs(dir_y );
bot[nr].x+= dir_x * -speed;
bot[nr].y+= dir_y * -speed;
}
the first part catches the distance booth x and y based towards the player of that particular bot.
The 2nd part divides it´s distance by its own positive value so that in the end you just get a 1 or -1. For example
-4,36 / abs(-4,36)
results in
-4,36 / (4,36)
results in
-1
the 3rd part moves that bot in a negative direction (-speed) so it moves away from the player
-
Senior Member
renderhjs I just dont like people who glue together random codes copied from forums, who then come back asking why it did not work.
-
Feeling adventurous?
If you don't want people to post code, how do you want us to help you?
I don't have a photograph, but you can have my footprints. They're upstairs in my socks.
-
Are you talking about something like this? This is an old game demo I made - the AI will check if the player is attacking and if he/she is, will dodge by either jumping away (if far from the wall) or jumping up and kicking off the wall (if close to the wall).
http://users.wpi.edu/~pgibler/Game/Game.html
-
need help to make th AI run away from character!!
Make sure you render a really big motherF%#*&# weapon, give it a really bada$$ name, and give it to your character. Works every time. You don't need any code. AI runs in the opposite direction on its own.
-
5+5=55
Originally Posted by MikeMD
Make sure you render a really big motherF%#*&# weapon, give it a really bada$$ name, and give it to your character. Works every time. You don't need any code. AI runs in the opposite direction on its own.
Another approach would be to simply rename your character to "Chuck Norris".
This will also make the enemies run away on their own.
-
I usually have timers assosiated with behaviour.
For example it takes a certain amount to scare them so say a bullet in the other direction increases their scaredMeter only slightly but a bullet towards is a lot and maybe 2 towards makes them run and one hit makes them run away. They choose a random location X Y to run to untill the meter lowers again and they go back towards the player (assuming you wish them to try and attack you) to pick a place to run to have a var safeDist = 200 (or whatever) and have it choose safePlace = (safeDist+random(safeDist/2));
if(scared){//direct enemy to safe place}
just use the code to fire bullets in the direction the player is facing to find the safe spot.
-
Another approach would be to simply rename your character to "Chuck Norris".
Absolutely, how could I have forgotten that one. That is the most fool proof way.
-
Quote:
Another approach would be to simply rename your character to "Chuck Norris".
Absolutely, how could I have forgotten that one. That is the most fool proof way.
Unless your AI characters are sexy babes, in which case it may catastrophically backfire.
-
Now tell me whos watchin......
Did u know chuck norris' tears cure cancer? Too bad he never cries.
-
Originally Posted by Giblaz
Are you talking about something like this? This is an old game demo I made - the AI will check if the player is attacking and if he/she is, will dodge by either jumping away (if far from the wall) or jumping up and kicking off the wall (if close to the wall).
http://users.wpi.edu/~pgibler/Game/Game.html
yess!!! thats perfect
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|