how to make an actor run away from another actor
aracknor
Member Posts: 54
Hi everyone this is my first question of many, many to come. how can i make an actor (the victim) move normal but as soon as an actor (the predator) gets close, the victim tries to get away until it reach certain distance. This must be like the opposite of how to create a follower but i just can't figure it out.
Comments
Create 6 Game attributes
-VictimX (Integer)
-VictimY (Integer)
-Proximity (Integer) // set to desired effective radius.
-PredatorClose (Boolean)
-PredatorX (Integer)
-PredatorY (Integer)
In the Victim actor...
Constrain self.position.x to game.VictimX
Constrain self.position.y to game.VictimY
In the Predator actors..
Rule
When ALL conditions are valid:
When an attribute changes:
Game.Proximity >= magnitude(self.position.x-game.VictimX,self.position.y-game.VictimY)
AND game.PredatorClose = false
-----Change PredatorX to self.position.x
-----Change PredatorY to self.position.y
-----Change game.PredatorClose to true
otherwise
-----Nothing here
Back in the Victim actor...
Rule
When ALL conditions are valid:
game.PredatorClose = true
AND Game.Proximity >= magnitude(self.position.x-game.PredatorX,self.position.y-game.PredatorY)
-----Accelerate Toward: position x = game.PredatorX, position y = game.PredatorY (relative to scene), speed -100(minus is key!)
otherwise
----- add desired stopping/slowing logic here...
----- Change game.PredatorClose to false
I will test this and update if needed when I get home tonight...
Thanks
I had that written wrong.
http://gamesalad.com/game/play/65632
Thanks again I you been amazing.
I followed the fred tutorial and it worked perfect. Thank you for your all your help and and more important thank you for you patient.
Thanks