playMaker

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

Shawn Kilian

  • Playmaker Newbie
  • *
  • Posts: 43
  • Multimedia Designer
    • View Profile
Hello,

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 http://screencast-o-matic.com/watch/cbfv0KXFxI

Any ideas?  This is driving me nuts!

**UPDATE**
I continued to dig and found this post from user escpodgames who said:
Quote
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.

http://hutonggames.com/playmakerforum/index.php?topic=9027.msg43124#msg43124 is the direct link to the thread that solved my issue.
« Last Edit: May 01, 2017, 02:14:56 PM by Shawn Kilian »