Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do I keep the character away from enemies?
#5
//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);
      } 
}


The > I colored red must of course be a < for your code.


Try this code:



Code:
if (self.x-target.x)*((self.facing?1:0)*2-1) < 0 && (self.x-target.x)*((self.facing?1:0)*2-1) < 300){
 if (self.x-target.x > 0){left();}
 else {right();}




There might be something wrong the the brackets though (those things: ( ) ), so you might need to fix that if you're using this code.
Original character edits
Goku2021
LF2 Timelapse (open source mod)

Reply
Thanks given by:


Messages In This Thread
RE: How do I keep the character away from enemies? - by Memento - 09-24-2014, 07:08 AM



Users browsing this thread: 1 Guest(s)