How to detect when two specific instances of the same object are in the same animation?

Hey!

This should be super simple but I can’t figure it out

I have 5 instances of the same object (Switcher), each one with an IDSwitcher variable (1 to 5).
I just want to check if instance 1 and instance 2 are both in animation 1 at the same time, and then trigger an action (like Quit the game for testing purposes).

I could do it with scene variables, but I’m sure there’s a cleaner, more functional way without having to set so many conditions or extra variables.

Is there a proper way to compare two specific instances of the same object directly?
Feels like I’m missing something obvious

I think you possibly need to use ‘pick all’ on the second one.
IGNORE …even then though you’ve still got a switcher (switcher 1) in the pick list with ani 1, so unless you briefly change the ani of that one to 2 before you check switcher 2 - you get the same problem.
IGNORE THIS BIT…
switcher id=1 and ani=1 then change ani to 2
sub event: pick all switcher, swtitcher id=2, and ani=1 then quit game
sub event: pick all switcher, switcher id=1 then change ani to 1

The other way is ‘repeat for each’ and then add up the switchers with ani=1

My response was lazy and shody!
so i tested it …you only need to do this…

1 Like

In your situation you could also use

Object animation = 1
Object ID variable < 3
Number of picked instance of object = 2

It’s a shame that GD still doesn’t have an easy way to switch between instances. In Javascript you can choose an instance simply by putting the number in brackets.

ObjectName[0].getX()

2 Likes