Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: velketor on April 30, 2017, 07:59:09 PM

Title: How do I make the enemy sprite always look at the player? [SOLVED]
Post by: velketor on April 30, 2017, 07:59:09 PM
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 (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.