I’d like to create an enemy that follows the x of the player and by matching the x goes up, if the enemy is on the ceiling, the same thing would happen, but down.
If possible explain why the direction of gravity is not changed in this case.
Develop games in your browser. Powerful, performant & highly capable.
Because enemy.x and player.x are never exactly equal to each other.
Try using a range, or rounding the values.