Please help me make the computer choose randomly

im going insane trying to figure out how to make the game select a random enemy to move, for example, at the beginning of a match, a random set of six enemies will spawn in selected places, that already works, what i want to do is make so one of them moves towards the player and when he dies a random one from the ones that are left will star moving towards the player and im going insane watching tutorials and trying it out for my self PLEASE HELP

image

yes but how do i specify that its supposed to pick a random one after the passing of the first one?

and theres 11 types of enemies

I don’t understand what you’re asking there.

The first enemy dies, and I’m guessing you delete it from the scene. Then the pick random enemy will pick one at random from the remaining enemies.

you see, i have the code that says: when player stops moving, change the variable of turn to two

and when vari\able of turn is two enemie1 moves.

how do i implement the other enemies?

It may be quicker if you screen shot the events.

i dont know how to screenshot in a computer, and its all in portuguese anyway

One powerful feature of GDevelop is the ability to quickly change your event sheet from one language to another and back again with the File/Language option. This makes it super easy to collab projects with people all over the world or even get a wider audience of people that can help with your problem. Not sure about screenshots that probably depends on operating system.

I’m guessing when the enemy dies is when you choose a new random enemy?


Found it! Thank you!

the current code is making all the enemies move towards the player at once and not in turns but if i slightly change i can make only one enemy move towards the player and then die (in turns) but after that it doesnt pick another one to do that


The code mentioned above

It’s looking more complex than I imagined. I was picturing something like if it was the enemies turn, picking all the enemies of the group to see if they had a boolean like “Hey I’m chasing this guy” and if not, picking a random enemy and setting the “Hey I’m chasing this guy” boolean to true. Then if one of them did have the boolean true, moving that one till it died. But I think your project is a bit advanced for me to help with. However I can say that there are a lot of people here that will see immediately what to do so just give it a while for them to see your topic.

Then let me simplify it a little, how do I pick one object from a group and tell it to move? Bcs I can choose the condition “pick a random instance” but when I go to the action I can’t talk directly to the random one that was picked. How do I do that?

What if you assign an object variable to your enemy when it is picked?
Then you can apply the action only if the variable is equal to that one.

Yeah, ok, but how do I make an action directly to the picked one? Bcs when I use “pick a random instance” it doesn’t show me which one it picked

Your enemies must be in a group. Here I named it “enemies”.
Action:
Pick a random enemies
Change the variable picked of enemies to: set to 1

Condition: The variable picked of enemies = 1
Action: Do what you wish.

I did that, and in the part where I put whatever I wanted I put so the group enemies would have in then a force added towards the player and they all went at it at the same time, Wich brings me again to the question of: after I set to pick a random instance of a group, how do I tell that specific instance what to do?

Sorry for taking too long to answer, I just have a lot going on right now

You pick the random group object in the condition of an event. The actions of that event will only be applied to the randomly picked object. If you ad subevents to that event, only the randomly picked object will be acted on. It’s all about the scope:

In the box labelled 1 of the above image, the ObjectGroup refers to the one randomly picked object, and the actions and conditions are applied to that one only. The randomly chosen object is only referenced in the first event and it’s subevents

In the box labelled 2 of the above image, the ObjectGroup no longer applies to the randomly picked object. It’s no longer in scope.