Destroy OTHER objects on Collision Unity (2 Ways!)

The whole page is mad helpful but here’s what solved my error:

For a collision to register, the following needs to be true:

The objects needs a non-kinematic rigidbody and a non-trigger collider.

The other object needs a non-trigger collider.

One of the colliders needs to be convex.

Both objects needs to be in layers that are set up to register collision (project settings -> physics).

For a Trigger Collision to register, the other object needs a convex collider set to IsTrigger = true. Note that Addyarb posted an example that uses OnTriggerEnter. For a normal collision, you would use OnCollisionEnter():

void OnCollisionEnter(Collision collision){
Destroy(collision.collider.gameObject);
Destroy(gameObject);
}

Link to full question and answer page: https://answers.unity.com/questions/1077612/destroy-other-objects-on-collision-unity.html

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.