Differentiating multiple Object Instances?

I have hard time using multiple object instances in one event.

Such as, i want to delete object instance1 whenever it is x pixels away from object instance2.
Or if instance1 is in collision with instance2 or instance3.
The Problem is, on both examples the condition picks the original instance (it checks whenever it is x pixels away from itself or checks if it is collided with itself)

I thought about using UID’s but I still don’t know how to make it work.

How do want to decide which instance gets deleted? An ID is 1 way to pick just 1 object but how are you choosing which ID?

Conditions work like filter. You can use any condition to picks an instance. Check an ID, a boolean, the animation name, pick a random object or Pick the object closest to x, y or the health or speed or anything.

What’s your criteria? What are the objects?

I recommend at the start of the scene, running a foreach loop for all of these instances and giving them a variable (id). This variable will increment with each instance so no two instances can get the same id.

Hi, yes that’s what I always do but often times this won’t help
like I want to stick two object instances together, how would that even be possible?

stick instance1 to instance2 obviously won’t work because its sticks the instance with itself.

While instances are efficient, somethings just aren’t practical or possible to do with instances of the same object.

You could pick one instance and save the x, y in a scene variable and then pick the 2nd instance and change its position based on the scene variable but depending on your needs it might not be practical since it might be much easier to use 2 objects and stick them together.

I guess you could use a 2nd object on the objects like a hit box. You could stick the 2nd.object to it or stick both objects to it. I don’t know what the objects represent.

What exactly do you want to make?

1 Like

While OP has not elaborated, I believe they need stick to account for rotations without having to do fancy math. It is still possible though and I have done it. It’s just annoying to set up.

Hi, yes that’s what I normally do, create a second object and use this one to stick to.

What do the objects represent? I’m just trying to get a better idea of what is happening. Dealing with multiple instances of an object can be a challenge but it can also be a big time saver. There are so many different ways to approach things.

Object variables help. For each object can help. Sometimes you need to kind of start over and use pick all objects There’s also pick nearest and pick random

It can also help if you arrange the events and subevents so you can reuse previous pick lists without having to repick things.

1 Like

I have an idea. Take a look inside “stick”’s function and recreate it except you pass in objects ids