How to enter name of the GameObject in OnCollisionEnter

I’m using OnCollisionEnter to check if GameObject are collides with the ground. But what if I want to enter name of the GameObject, which I want to check on collision?

public GameObject player;	
bool isGrounded = false;

void Start ()
{
    player = (GameObject)this.gameObject;
}

void Update ()
{
    if(isGrounded == true)
        //..	
}

void OnCollisionEnter(Collision collision)
{
    isGrounded = true;
}

Hey, do you mean something like this?
BTW (This piece of code has to be assigned to GameObject which collides with GameObject called “DesiredGOName” in script)

    private void OnCollisionEnter(Collision collision)
    {
        // Get Name for colliding object
        if (collision.transform.name == "DesiredGOName")
            IsGrounded = true;
        else
            IsGrounded = false;
    }

I think that You probably want to check if the objects that Your player collides with is actually ground and not something other. If yes than You can use this to get object that collider collides with Collision.gameObject . So You can use (Collision.gameObject.name or Collision.gameObject.tag)

If thats not your aim than You can find gameObject by name with GameObject.Find
But also be aware of that:

For performance reasons it is recommended to not use this function every frame Instead cache the result in a member variable at startup or use GameObject.FindWithTag.

Hope that this is going to help You in some way :wink: