Only one sub-event executes on enemy collision – need help

Hello Everyone!

Here are the events that manage the movement system for the enemy object group. The goal is that when an enemy (here object group “Ennemis”) collides with the player, it should move back in the opposite direction. It almost works, but I’m encountering an issue with the event “enemy is in collision with player” and its two sub-events: “the variable estTourneADroite of enemy is true" and “the variable estTourneADroite of enemy is false”. variable “estTourneADroite” (in English gototheright) is a Boolean variable. Only the second condition (“estTourneADroite is false”) and its actions are being taken into account by GDevelop. If I disable it, then the first sub-event (“estTourneADroite is true”) works. So I don’t know how to make GDevelop consider both conditions properly.

Could you help me please ?

Many thanks!!!

Hi @Ka-p-llo!

Avez-vous correctement inittialisé (à FAUX ou VRAI) votre variable booléenne “estTourneADroite” au début de votre jeu ?

A plus
Xierra

Have you properly initialized (with false or true) your Boolean variable “estTourneADroite” at the start of your game?

The issue is that in the first subevent, when estTourneADroite is true, it gets set to false. Then, in the subevent immediately after, estTourneADroite is false and so the event is actionsed, and estTourneADroite is set back to true.

If you only want to swap estTourneADroite from true to false and vice versa, then the simplest solution is to get rid of the two subevents, and in the main event use the action “Change the variable estTourneADroite: toggle”.

Hello !

I’m sorry for my late response, I was quite busy these days.

Many Thanks for your help both of you Xierra and MrMen