void OnCollisionEnter2D (Collision2D col){
if (col.gameObject.tag == "Throwable") {
Destroy (gameObject);
}
}
This just destroys the gameobject who has script on it. But I want to destroy other object that collides with this object. Couldn't find the answer. I think there is an answer on unity3d(I assume from title) but somehow I can't connect the site. Also I tried them
Destroy (other.gameobject);
Destroy (gameObject.tag == "Throwable");
Didn't work anyways.
void OnCollisionEnter2D (Collision2D col){
if (col.gameObject.tag == "Throwable") {
Destroy (col.gameObject);
}
}
where col.gameObject it the incoming GameObject involved in the collision.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With