Enemy constantly flips while moving

Make an enemy for my platformer game that will turn and go back when it detects a wall

what should happen is the enemy walking to the wall, flipping once, and then walking back. doing this in a loop

What is happening is the enemy is turning at the wall as expected but rapidly flipping while moving

i tried to copy the code from the official gdevelop enemy tutorial and it doesn’t appear to work for me.

Hi ..it’s one of those where the event above is triggering the event below. Cures for this are an object timer ‘turn’ starting each time it turns and then a condition on the turn event ‘turn’ timer of object greater than .1s. start timer on object creation. Or possibly ‘trigger once’ or a Boolean variable ‘has turned’ but this might not work if it’s moving quickly. Or you could use ‘turn right blocks’ and ‘turn left blocks’ or an object var attached to ‘groundset’ called ‘turn’ which can be 'left’or ‘right’

Edit: your movent lines might be backwards. It’s moving right when flipped and left when not flipped. I think it should be reversed. Flipped, left and not flipped, right. Otherwise it will get stuck bouncing around a wall.

You can simplify it using the Else event.

https://wiki.gdevelop.io/gdevelop5/events/else/

Where is your point located. I named mine “Lead”

If the point is too close to the center or it’s moving extremely fast then when flipped, the point could still be inside the wall.

This could be solved with an ELSE event: