issue with ai movement
chandan1014
Member Posts: 14
ok i got stuck again. this is the expression i use to make my ai move away from the fire:
(vectorToAngle( game.fire.Position.X - game.playerPositionX , game.fire.Position.Y - game.playerPositionY ) + random(20,90))
here, playerPositionX and playerPositionY are the players position form where he fires and fire.Position.X and fire.Position.Y are the coordinates of the position where the player chooses to fire. finally i use a random number to add to the overall angle received from the vectorToAngle to make the ai actor move away from the projectile.
so while my ai actor moves away from the player fire, it moves in only one direction and gets stuck at the screen boundary, up in this case. what i want is my ai actor to be able to move in both in up and down directions, judging by whichever screen boundary is at a further distance from the ai actor. any idea on how can i make it happen?
(vectorToAngle( game.fire.Position.X - game.playerPositionX , game.fire.Position.Y - game.playerPositionY ) + random(20,90))
here, playerPositionX and playerPositionY are the players position form where he fires and fire.Position.X and fire.Position.Y are the coordinates of the position where the player chooses to fire. finally i use a random number to add to the overall angle received from the vectorToAngle to make the ai actor move away from the projectile.
so while my ai actor moves away from the player fire, it moves in only one direction and gets stuck at the screen boundary, up in this case. what i want is my ai actor to be able to move in both in up and down directions, judging by whichever screen boundary is at a further distance from the ai actor. any idea on how can i make it happen?
Comments
http://www.zaimoni.com/grafx/UnitCircleW_Quadrants.gif
So your enemy is always going to move between 20 and 90 degrees. Which is up-ish.