How to Destroy a GameObject on Collision in Unity.

There are many reasons why you would want to destroy a gameobject in your app. Depending on the situation, you can use a specific function to make this happen, such as OnCollisionEnter(). To destroy a gameobject on collision, use the OnCollisionEnter() function for the collision itself and the Destroy() function to destroy a gameobject when…