A Flash Developer Resource Site

Results 1 to 16 of 16

Thread: how to make AI RUN away

  1. #1
    Member
    Join Date
    May 2008
    Posts
    48

    resolved how to make AI RUN away

    i need help to make th AI run away from character!!
    help

  2. #2
    Script kiddie VENGEANCE MX's Avatar
    Join Date
    Jun 2004
    Location
    England
    Posts
    2,590
    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.
    http://www.birchlabs.co.uk/
    You know you want to.

  3. #3
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    by letting them move in the opposite direction of the player towards the AI bots
    simple question simple answer

  4. #4
    Member
    Join Date
    May 2008
    Posts
    48
    can you give me only a top view AI please only

  5. #5
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    927
    Quote Originally Posted by askentoyou
    can you give me only a top view AI please only
    here
    who is this? a word of friendly advice: FFS stop using AS2

  6. #6
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    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.bot[nr].x;
        
    dir_y player.bot[nr].y;
        
        
    dir_x/= Math.absdir_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

  7. #7
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    927
    renderhjs I just dont like people who glue together random codes copied from forums, who then come back asking why it did not work.
    who is this? a word of friendly advice: FFS stop using AS2

  8. #8
    Feeling adventurous? T1ger's Avatar
    Join Date
    Mar 2004
    Posts
    850
    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.

  9. #9
    Member
    Join Date
    Nov 2003
    Posts
    90
    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

  10. #10
    Senior Member
    Join Date
    Sep 2004
    Posts
    633
    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.

  11. #11
    5+5=55 Schfifty Five's Avatar
    Join Date
    Jun 2006
    Posts
    698
    Quote 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.

  12. #12
    Junior Member
    Join Date
    Feb 2005
    Location
    uk... fine thanks
    Posts
    3
    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.
    //over and out

  13. #13
    Senior Member
    Join Date
    Sep 2004
    Posts
    633
    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.

  14. #14
    Senior Member
    Join Date
    Mar 2008
    Posts
    301
    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.

  15. #15
    Now tell me whos watchin...... samvillian's Avatar
    Join Date
    Feb 2007
    Location
    Where do you live?
    Posts
    539
    Did u know chuck norris' tears cure cancer? Too bad he never cries.
    If the only tool you have is a hammer, you tend to see every problem as a nail.

    Xbox 360 Modding Controller PS3 Mod Paint Spray LED Case

  16. #16
    Member
    Join Date
    May 2008
    Posts
    48
    Quote 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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center