Compare Values of the same Object Instances?

I need to compare a instance variable with other instance variables from the same object. The problem I’m facing, the „for each object“ loop compares the given variable with itself and not with other instance variables (but itself).

Isn’t that something needed often? Am i missing something?

Object1.ID = Object1.ID
Delete Object1

This does not delete every instances with the same ID, but it delets just every instance.


IDK if it would work but

For each event
Variable ID of Object is equal to Object.Variable(ID)

Delete Object

1 Like

That’s the problem, it just compares the variable with itself and not with other object instances.

How about instance ID?

Variable ID of Object is NOT equal to Object.Variable(ID)
Variable SOMEVAR of Object is equal to Object.Variable(SOMEVAR)

Delete Object

I see 2 solutions either the for each object or a variable used within a repeat. I don’t know how many numbers are used as IDs so I don’t know if it would be efficient to go through the first x number of IDs using a repeat and another variable that gets increased each time.

I like the repeat as sort of a for…next setup because I don’t know what would happen if you deleted future objects in a for each object. I don’t know if it would just carry on as normal, loose it’s place or some other issue.

Repeat 50 times
Variable of object =i
Number of picked objects >2
–Delete object
I +1


For each object
Set v to object variable

Sub event
–Select all objects
–Object variable = v
–Number of picked objects >1
----Delete object

Again using the „for each object“ loop on that, it just compares the ID variable of every instance with itself, therefore it’s false and nothing happens. It does not compare the ID variable of every instance with every other instance (except itself) but that’s what I need.

Isn’t comparing an instance variable with other instance variables from the same object something that’s needed often? Am I missing something?

I would try it without for each
Even go as far as with Pick all objects condition/action first
Then check if instance variable IS NOT EQUAL (maybe that would not even be needed)
And then at the end check if that ID variable IS EQUAL
Be aware instance variables and ID variables are 2 different things

And to answer if it often needed
I do not track i was there like 2 or 3 times
BUT i sit on discord help channel and MOST like lion share games i see ppl try to make are either platform/topdown shooters or infinite platform runners
Hard to shove in there need for comparing variables of same objects
Where it is either hp that matters and if it is 0 to know if enemy should die or not

It is rare case when i see ppl that would actually benefit from comparing variables of multiple of objects in their projects
More often i see ppl who would benefit from checking collision for multiple of same objects and then separating them

1 Like

These work for me.

This just checks 0 to 5

1 Like