How to get every pairs of instances from same object?

it still dosent work even if putting it in different group…

Hi and welcome here :slight_smile:

The Pairs example project proceeds like so:

To add to what @Gruk has written and briefly explain why it your attempt won.t work :

AppleGroup1 initially has all the instances of the object to choose from, as does AppleGroup2. But when you iterate through each object in AppleGroup1, each iteration filters the list of objects just down to one object at a time. And it’s this filtered list that AppleGroup2 works with - it has only the one object to iterate over.

It would help though, if you could tell us what you are trying to achieve. Because that can change how the problem is tackled. The Pairs example works because pairs of objects on the screen share the same Id. However, this won’t work if you want to pair up any 2 random objects.

Thanks for the replys.

My situation is something like an Enemy1 can attack another Enemy2 and they both are same object(Enemy) but different instances.

That’s mean i have to do something actions like move Enemy1.position toward Enemy2.position.

And then i found i can not have two references for these instances, Enemy1 and Enemy2, in one action.

Like this,
foreach en1 in Enemy
----foreach en2 in Enemy
---- ----if en1.targetId ==
---- ---- ---- then move en1 to en2.position

but it can not work as what i expect in Gdevelop.

I find a solution is It seems i have to use “scene variable” to make these two instances communicate.
Or just to make many different Enemy Objects but not instances.