(Solved) Attaching Objects around Multiple Instances

So I’m running into a problem with attaching an object between two instances. Every time I create the Object 2 times have it go to the enemy position and then attach to both instances but It only goes to the first or last one created.

Image to add Context to my problem (The Issue I’m seeing)

The Result I want

Here is a look at my code. Can anyone tell me what’s wrong here?

Old Code - Doesn’t Work

New Code - Doesn’t Work

You cannot use the Trigger Once condition with “For Each” events. It does not do what you expect, and will make the events either occur only for the first instance or occur infinitely.

You will need to use a boolean object variable, named something like “WeaponCreate”, and in your (single) subevent have a condition checking that it is false.
You will then add the actions tocreate your weapon and link the enemy and weapon (also these have to be in the same event box otherwise they do not actually link the created object).
The last action you will have will set the object variable to true. This will ensure that the create only happens once for each enemy.

Your link/movement event should be fine from what I’m seeing here.

@Silver-Streak Can you give me a code example so I can understand it a bit better?


This works for me:
https://game-previews.gdevelop-app.com/1662824006346-220619/index.html

You can click and drag any parent object.

Note: Keep in mind the order of objects in the “link” event actions and conditions DO matter, so make sure you have them in the right order when using them.

1 Like

Thanks, Greatly Appreciated!