Outputting console code upon object collision.

Here’s what I’ve tried so far:

(Inside the object’s code)

void OnCollisionEnter(Collision collision)
{
    Debug.Log("Collided with something");
}

Unfortunately this doesn’t work. I only want to output code when a certain object collides with anything but the floor.

Assuming you name the floor “Floor”:

void OnCollisionEnter(Collision collision)
{
    if (collision.collider.name != "Floor");
        Debug.Log("Collided with something other than the floor");
}