OnCollisionEnter
The OnCollisionEnter method is a built-in function in the Unity game engine used to detect and respond to collisions between colliders in real-time. It is part of the UnityEngine.Physics namespace and is commonly employed in C# scripts attached to GameObjects with colliders. The method is specifically designed to handle collisions that occur when two colliders enter contact with each other, triggering the event once per collision.
When a collision is detected, Unity invokes the OnCollisionEnter function, passing a reference to the Collision
Unlike OnTriggerEnter, which is used for trigger colliders, OnCollisionEnter is reserved for rigidbody-based collisions, meaning it
For optimal performance, developers should avoid heavy computations within OnCollisionEnter, as it is called frequently during