I am trying to get an enemy in a platformer to only fly up and down left and right towards the player - not diagonal. I have tried many things, but this seems like it should work:
If The Y Position of Enemy > Player.Y() then add to Enemy an instant force of 0 p/s on X axis and -80 p/s on Y axis
If The Y Position of Enemy < Player.Y() then add to Enemy an instant force of 0 p/s on X axis and 80 p/s on Y axis
If The Y Position of Enemy = Player.Y() then move Enemy toward Player with an instant force of 80 p/s
The problem is the Y position is never equal to the Player.Y()! The enemy will fly up and down and match the players Y position, but then it will just twitch up and down and never move left or right. What am I missing? How does it move through the equals to without ever reaching equal?
Update:
This doesn’t work either. I’m so confused: Why are they never equal?
If The Y Position of Enemy > Player.Y() and The Y Position of Enemy does not equal Player.Y() then change the Y position of Enemy subtract 1
If The Y Position of Enemy < Player.Y() and The Y Position of Enemy does not equal Player.Y() then change the Y position of Enemy add 1
If The Y Position of Enemy = Player.Y() then move Enemy toward Player with an instant force of 80 p/s