Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do I keep the character away from enemies?
#2
Maybe you write it so if they are facing the enemy they turn the opposite direction and double tap that direction to run away. And if they are facing opposite direction they double tap that direction to keep running that way.

I made a script so the AI runs towards someone if they are a certain distance away.


Code:
//run after enemy
if (abs(self.x-target.x) > 450) {
    if (self.x-target.x > 0){
        left(1,0);
        left(1,0);
      }  
    else if (self.x-target.x < 0){
        right(1,0);
        right(1,0);
      }
}
It's pretty crap code cause I'm a crappy programmer
Reply
Thanks given by:


Messages In This Thread
RE: How do I keep the character away from enemies? - by bashscrazy - 09-23-2014, 12:36 AM



Users browsing this thread: 1 Guest(s)