Question by
Cryno1000 · Jan 12, 2020 at 06:25 PM ·
spritespriterendererif statement
Change sprite based on movement direction
Hi, I'm making a 2D game where enemies chase the player, but I'm having trouble changing the enemies sprite based on the movement direction. So like if the player is to the right of the enemy, I want to change the sprite to moving_right.
So like
// if player is to right of enemy {
this.gameObject.GetComponent<SpriteRenderer>().sprite = moving_right;
}
Thanks in advance!
Comment
Your answer
Follow this Question
Related Questions
How to check if two sprites are the same 2 Answers
How can I have multiple sprite objects turned into one sprite object 0 Answers
assigning sprites to game object via script 0 Answers
Sprite Bug when move 1 Answer
Sprites Pink After Upgrading Unity 1 Answer