How to destroy an object without using tags on collision



Hello.

What do you mean with “without using tags” ?

When doing a collision or a trigger function, you need to specify what collider is what you want to interact with…

It can be any variable, property, tag, layer, parent… anything, but you need something to specify unity what collider is what you want to interact, if not, all colliders will do what you typed inside the Oncollision

void OnCollisionEnter(Collision collision)
    {            
        Destroy(Collision.GameObject);
    }
//This code will destroy 100% of colliders that hits, all of them, the floor, props, everything that contaiins any kinf of collider...

So you seed to specify, examples:

void OnCollisionEnter(Collision collision)
{
if (Collision.GameObject.name.Contains("Enem") )Destroy(Collision.GameObject);
else if (Collision.GameObject.transform.parent == null) Destroy(Collision.GameObject);
else if (Collision.GameObject.GetComponent<SomeScript>() != null) Destroy(Collision.GameObject);
else if (Collision.GameObject.transform.position.x <= 125) Destroy(Collision.GameObject);
else if (Collision.GameObject.layer == 3) Destroy(Collision.GameObject);

}

Bye.

Destroy(collision.gameObject);