Sprites don't flip (SOLVED)

In my game, I have an enemy that likes to bounce around. To make the enemy flip around when it meets a solid object, I put a special hitbox on it’s face. The plan is that if the linked special hitbox touches a wall, the enemy turns around. Here is how I did it:

There’s one problem with this code though, and I can’t figure it out. I think it’s best if I show you:

As you can see, the bouncy enemies (With the help of the special hitbox) turn around once they hit the left wall. However, once they hit the right wall, they get stuck when they should be turning around.

I’m kinda stumped on this one. Can someone please help? Thanks ^^

Problem is when you evaluate if chompie is horizontally-flipped and then you make it not-horizontally-flipped, the next event evaluates if it’s not-horizontally-flipped… and now it’s not-horizontally-flipped! so it gets immediatly horizontally-flipped again and so in the next frame and to the eternity (it gets stuck)…

Do something like this:


Thanks, it works flawlessly now ^^
However, I’ve got a quick question.
I used an object variable instead of a scene variable. These enemies are going to be used in multiple scenes. Would it make a difference to use scene variables instead?

1 Like

In fact, that’s exactly what you need: to use object variables. I overlooked that.

That will not affect the use of the enemies in other scenes, those are different instances of the same object.

1 Like