Okay, so I'm setting up an NPC that will look towards me as I move past.
I set up three animations, one with his head looking foward, one looking right, and one looking left.
I can easily make the person look left or right. The problem I run into is making them look forward again.
I actually did accomplish this, but I had to use trigger boxes. I set it so if the player is overlapping them, it sets the NPC's look animation. I have one for left, one for right, and if overlapping neither to look forward.
However, that method will add to the object count, and is not the optimal solution. That and I have to add these trigger boxes (sprites) in with every instance of an npc.
I wanted to do it with code. You know something like compare x. I had it working, but I couldn't get it to work with looking forward. I tried using "else." I tried using inverts. And so on, but nothing worked. It always either didn't look forward at all, or it ended up overwriting the look left command or something.
Also, I set it up so there is some play. I added +200 for the right, and -200 for the left so the NPC would look forward when you start to get close rather than when you are on top of him.
I'm using playerHitBox as my main thing in the events. So, if my hitbox is to the right or left, it makes the npc look.
Ex: (X < npc.x -200) or (x < npc.bboxleft -200) to look left
or (X > npc.x +200) or (X > npc.bboxright +200) to look right
Can anyone give me some guidance on what to do to make him look forward in between all this? I can't do it without interfering with one of the other directions. Thanks!