[Solved] Platformer Enemy Not Turning Around at the Edge of a Platform

Before proceeding, please use the forum search feature at the top of the page to check if your question has already been answered.

How do I…

So I have an enemy sprite with the platformerObject behavior that I would like to be able to move left to right on a platform (the platform has the platform behavior), turning the other way when it reaches the edge. However, using a point on the sprite in front and slightly below from the sprite, it turns around when approaching the right side but falls off the edge when approaching the left side. Although I know that you can use objects to mark the edges, I was hoping to accomplish this without extra objects so that it could be more dynamic for things like puzzles. It’s probably something obvious but I do not understand why it does not work.

What is the expected result

I would like to be able to have the enemy move from left to right on a platform, turning the other way when it reaches the edge.

What is the actual result

However, using a point on the sprite in front and slightly below from the sprite, it turns around when approaching the right side but falls off the edge when approaching the left side.

Related screenshots

Project files (optional)

Here is a link to a playable output

Hello, glitchedPapaya

When you check the enemy.Point if it’s inside of the box your subevents always finish with enemy been flipped, because if the first subevent is true the second will be too. Gdevelop read the events from top to the bottom.

I think the solution could be use a variable. I did this:

1 Like

Thank you Rasterisko!!! Your solution worked like a charm. Once I inverted the point collision check it was perfect

1 Like