Search Unity

Weird issue with OnCollisionEnter

Discussion in 'Scripting' started by BiffCornwall, Nov 15, 2009.

  1. BiffCornwall

    BiffCornwall

    Joined:
    Nov 15, 2009
    Posts:
    1
    I have a very simple setup (just started with Unity, so keeping it simple) of a plane with a rigidbody cube sitting on top of it, with a rigidbody sphere hovering directly above the cube. I have created a script called "Collision.js" which has the following:
    Code (csharp):
    1. function OnCollisionEnter(collision : Collision)
    2. {
    3.     Debug.Log("Collision: " + collision.gameObject.tag);
    4. }
    When attempting to run the game, I always get this error:
    Code (csharp):
    1. Script error: OnCollisionEnter
    2. This message parameter has to be of type: Collision
    3. The message will be ignored.
    Does anyone know why this is? It's very perplexing, as I'm doing (seemingly) exactly what the compiler is complaining about me not doing, which is setting the parameter to the type "Collision"...

    Thanks in advance for any help.
    Biff
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Make sure it really is "Collision" and not "Collider" or something else.

    --Eric