Please help me make the computer choose randomly

so, how do i make it so one of the random objects is the part of the group that is spawned? bcs this did not work and i supose its bcs its choosing another object that is not sspawned therrefore cannot move

Can you screen snip what you’ve done?


You’ll need to use something line the following, it’s along the lines of what @zutty was suggesting:

it didnt work and i think its because in your example you used a single object with a bunch of ccopies and im using a group with multiple enemies

It shouldn’t matter if it’s on object or a group. Can you screen snip your events?


though the second one might be relevvant

You have not done what I had in my screen snip, and so your events won’t work the same.

How, in the screen snip below, does GDevelop know which inimigos to move? You are telling GDevelop to move all inimigos, because you have not filtered them with a condition.

I used the is_chasing boolean variable on the object to indicate that is the one to move. You’ll need do something likewise.

but how will i add a variable to a group

Ideally, you add it to each object in the group.

But, if you set an object variable and the variable doesn’t exist on the object, GDevelop will create it and set it.

ok so it worked but then i added this in addition to the other lines of turno and now just one enemy moves ignoring the second image


Can you screen shot all the relevant events, like you did earlier on? I think I know what may be going on, but cannot be sure if I don’t have the complete picture.


Uploading: Captura de tela 2023-12-01 231449.png…

What about the events that move inimigos?

The inimigos with the is_chasing variable set to true is being moved every frame, regardless of which turn it is.

Add a condition to check if turno = 2 to this event:

it worked but when the first enemy dissapears the second one is paralyzed

In this event:

as well as the move action, add the action to set the variable is_chasing to true for inimigos.