0
\$\begingroup\$

I want to make sure that no two instances of obj_A are overlapping, but can't seem to figure anything out, because instance_position, instance_nearest and the like will include the instance running it, so if I had something like:

if instance_position(x,y,obj_A)!=noone
{
    with(instance_position(x,y,obj_A))
    {
        instance_destroy()
    }
}

All instances of obj_A will destroy themselves because they think they are overlapping with themselves.

\$\endgroup\$
1
\$\begingroup\$

This is what worked for me:

with(obj_A){
    if (id!=other.id) and (place_meeting(x,y,other)){
        instance_destroy();
    }
}

As it turned out, I just needed to compare the instances' id's.

|improve this answer|||||
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.