How do I Pin multiple weapons to enemies

Hello!
I’m creating a Top Down Shooter game were weapons are pinned to the characters and rotate on their center.
I’ve created a random spawn of enemies and every enemy should spawn with the same weapon.
Now the weapons spawns and the enemies spawns but all the weapons are pinned only to the first instance of a enemy that spawned.
I’ve tried the “For Each” Function but it doesn’t work or it’s me that i don’t use it properly.

Showing your events might help us help you :wink:

Yes Sure!
https://imgur.com/a/GFFfzkr
Those are the events for the random spawn of the enemies and weapons
https://imgur.com/a/cYVynu3
This is the event that should pin the weapon on each enemy.
For the second screen: I’ve tried to do this in different ways but this is the only screen i have unfortunately

P.S: It could be that the images are not displayed correctly, just open them and it should fine.

Please use the forum hosting for the pictures, just drag them or copy-paste them where you write.
It will be easier to read and safer for future viewers.
And don’t show us bits of events that are not on the same sheet at the same time, it will cause confusion. Troubleshooting an issue without having the full project at hand is hard enough as it is. :sweat_smile:

Maybe you could do, “for each enemy, if there is no weapon inside the enemy, create a weapon”. Just a guess.

Oh Sorry. I’m not “practical” with the forum :sweat_smile:.
Thank you anyway for your help, I just want to ask you one more thing: How can I tell the program to check if an instance doesn’t have a weapon?
Sorry even for the bad screenshots , my bad. :sweat_smile:

but as I said, it’s just a guess.

Ok i will try!
Thank you.

I’ve tried with this:


But what happen is that all the weapons spawns on only one instance and then they move their position to the following instance that is spawned.
The result is that only one instance have all the weapons and this instance is the last one created.

There’s a problem with your event because it says, if the existing gun is not inside the gunner, create a gun. :thinking:
Maybe my guess wasn’t a good guess :sweat_smile:
It’s probably safer to create each gun when you create each gunner.

That’s what I did in the first screenshot I sent.

I’ve created this in a test project:


basically every instance of “Enemy” has its own variable called ID and every instance of “Gun” has its own variable called Parent (par). For each Enemy object, if the two variables are equal change the position of each gun.

And it works!

But this only working if i have the exact number of how many guns and how many enemies are in the scene.
I wonder how to do this with the random spawner of the enemies and guns.:thinking:

hi, maybe you should link guns to enemies, so each enemy will have its gun linked