How do I implement more instances of objects with the same AI?

Hi
I know the title could be a little silly.
but it’s the more complete title.
So I’m making a Top-Down shooter with dual stick, and at the moment I’m trying to create a bunch of enemies to have a good selection of enemy to insert in the room.
So now I’m facing one technical problem, one of my enemy have a gun as linked object, the behavior of this enemy should to go to the player, stay in position if the distance with the player is minus then 200px. And after this start shooting 3 bullets each 1 sec. (this timing is an example).
To achieve this I add to the gun object 4 animation, the first 3 animation need to be loaded in sequence, after one animation finish the run, one bullet is fired, and the second animation is loaded, after the second animation a second bullet will be fired, and the third animation will start, and so on.
After all this animation on the gun, a new animation will start to give a delay time for the enemy to shoot again.
Now, all this thing when I have 1 enemy (and so also 1 gun) in the scene is perfect and works fine. But when I add another enemy (so 2 guns, one for enemy) no one start shooting.
In attach what I have done on script (is a little dirty 'couse I have done a lot try)


But at this point I have another question, If I want to try to achieve a gameplay style similar (but obviously more simple) to Enter in the gungeon or Isaac, I have to re-think my project? I see on Gdevelop is possible to create a room generator and a top-down shooter, but I’m getting a lot of problems to manage multiple instance of the same enemy with an IA a little bit more complex than “go to the player”.

P.S.
If the only problem here is I’m dumb, I can understand 'couse I have been using Gdev for a week :confused:

You should be using the same object (or group) in the two lines:
image
Repeat for each Group - Take into account all weapon linked to Group.

Otherwise, GDevelop repeats the event for each item of the group, but picks a random EnemyDaft2 each time.

Hi Gruk

So i should use the for each instance for each action?
I tried to change the EnemyDaft2 to the group, but nothing change.

Have you made sure to change everywhere needed?
Please share updated screenshots. :slight_smile:

Yeah sure

This is what I have done, but nothing change :frowning:

![2|690x342](upload://e6xVNPtS4OfuyygPTb5ngFSerLG.png)

This part doesn’t seem to be inside a “for each”:
image

And either use the object or the group, but don’t mix both or GDevelop doesn’t know which instances it should pick.
image

I set the group insted of object, and set the forEach, but it dosen’t work, maybe I have to use the weapon in the foreach loop?

If you apply to each group item and use the “take into account”, I don’t think it should matter, but feel free to try.

I tried to use the Weapon2 in the foreach loop but nothing work

maybe there is another way to do that?

There are surely several ways to proceed, but whichever way you choose, the events all need to be correctly set up.
Clean up your events sheet and proceed step by step.