Author Topic: How do I make the enemy sprite always look at the player? [SOLVED]  (Read 523 times)

Shawn Kilian

  • Playmaker Newbie
  • *
  • Posts: 49
  • Multimedia Designer
    • View Profile

I want my enemy Sprite to always look at the Player.  When the player gets in range, I have a trigger that sets the Property on the enemy Sprite Renderer to Flip X to get the enemy Sprite to look at the Player.  However, it doesn't know if the Player is on it's right or on it's left so the enemy Sprite gets stuck facing the wrong direction.

Here is a short video of what is happening

Any ideas?  This is driving me nuts!

I continued to dig and found this post from user escpodgames who said:
You could...

Get the enemies Xposition
Get the players Xposition
Subtract the enemies Xposition from the players Xposition
Compare the results, greater than 0 would set the Xscale to 1 and less than to -1.

I did this and it actually worked!!! Thank you so much.  I truly appreciate your help. is the direct link to the thread that solved my issue.
« Last Edit: May 01, 2017, 02:14:56 PM by Shawn Kilian »