unity use oncollision enter code example
Example 1: unity oncollisionenter
void OnCollisionEnter(Collision col)
{
//This method will run when your game object
//collides with something
Debug.Log("Collided");
}
Example 2: check for collision unity c#
void OnCollisionEnter(Collision col) { }