[SOLVED] Move enemy stop him then move again

So… first of all hello everybody i’m really new to Gdevelop and i want to create a platformer game. I want an enemy to move to the left then stop for a few seconds and then move to the right

I can make him move left and right with variables without any problem

But when i try to add timers and stuff to make him stop and then move again nothing happens… the enemy moves to the left then stops when it’s in collision with “right” and stays like that

Thanks in advance

I think it might have to do with the guard being in collision with left/right. As long as there is a collision, the timer is being reset every frame. Therefore, it never gets to 2 seconds. Adding a “trigger once” would allow the timer to only reset once and be able to get to 2 seconds.

Hi thank you for your reply
I added “trigger once” but the enemy just kept running left or going crazy so I had to create a new variable to stop the enemy. But just like you said I added the “trigger once” condition when the enemy hits left/right to make it work. Thank you again man!

Trying to understand the logic here, the timers only triggers when the enemy is on “idle” so if the enemy is not in “idle” will move right?

So when you change the variable direction to 2 you need to check there which is going to be the new direction and not inside the timer event.

Look this logic

Every X seconds extension is needed.
So do
Condition:
– Every 2 seconds
----- guard variable direction = 0
----- Action:
----- Simulate Right
----- Do animation right

----- guard collision Left
----- Action:
----- Simulate Right
----- Do animation right

----- guard collision Right
----- Action:
----- Simulate Left
----- Do animation left

There is no need to idle unless you want the enemy to stay when collides to Left or Right if that is the case just add another event inside the Every 3 seconds to stop the enemy. and since this is going to be a loop timer every 3 seconds check again which is the player direction and move him.

You might look at the boss logic setup in the Not -A-Vania example.

While I’m using tweens instead of movement, the concept of “move to object > change state > Move to next objext > repeat” is pretty much exactly how I set up the boss.

Sorry for the late response I was busy

I did look at that example and made some changes and now everything is working great! thanks a lot man.