Do I want to make an object change its direction to a random one when colliding with any wall?

Hi, I’m new to gdevelop. I want to create an enemy intelligence that moves through the stage and changes direction randomly on both the X and Y axis when it collides with a wall. How can I do this?

Welcome. What type of game are you making? A screenshot or more details would help. It’s a bit unlear.

I’m sorry, my English is not that good
I am attaching some images of what I want, but the events are in Spanish.

In the first image, it is the beginning of an object variable that will make a cycle from 0 to 3 where every time it collides with a wall NPC, it changes its direction.

Your English is fine. I don’t understand. What is supposed to happen? What is happening instead?

Have you seen the Adventure of Lolo video game? There’s an enemy that looks like an armadillo that collides with the scenery and changes its direction to the next one. I want to do the same thing with my enemy, but what happens is that it gets stuck to the wall and keeps changing direction constantly without detaching from the wall. Here’s a video of Adventure of Lolo as an example.

The exact minute when the enemy appears is 2:17, the gray enemy. I want to make a behavior like the one he has.

That helps a lot. Unfortunately, it’s not something I’m familiar with but I’m sure someone here can help.

Hi Wilmer, You need to use the ‘Bounce’ function in my humble opinion.
How?

  1. Create a “wall” just around your play area.
  2. When enemy collides with this wall, apply ‘Bounce’. It will push enemies away from the wall.
    Please have a look at this video: GDevelop 5 - Catch the Cue Ball - Bouncing a Ball (2 of 6) - YouTube

Is this something that helped you? Let me know.

Thank you, I’m going to try it

It didn’t work, the object is still not responding properly

I managed to solve the problem by implementing an object inside the enemy that works as a collision detector or raycast