I Wanna Community
Fangames => Game Design => Programming Questions => Topic started by: l3agu32 on May 10, 2016, 08:37:49 AM
-
I want the enemy's xscale to change when the player changes his side. For instance, if the enemy's x position is 400 and the player's x position is less than 400, the enemy should be facing the left. Thank you.
-
if (player.x > enemy.x){
image_xscale = -1
} else {
image_xscale = 1}
-
In one line of code:
image_xscale = sign(sign(enemy.x-player.x)+0.1)
enemy.x can be replaced with x if the instance calling is the enemy. And player.x can be replaced with x if the instance calling is the player.