UnityScript Problem

Now I am currently developing a 2D game in Unity 4.6 and I am having a problem with my code. The script wont detect the collision between two objects (player & floor) and thus wont change the variable of "grounded". I'm trying to avoid a double jump and I am making it so that as soon as the collision between the player and the ground - or wall - has been detected they can jump again. But I cant seem to get it right.

Here is the part of the code for help:

function OnCollisionEnter (onCollision : Collision) {
    if(onCollision.gameObject.name == "Clouse") {
        grounded = true;
    }
    else {
        grounded = false;
    }
}

This code is outside of function update because every time I insert it I get a few errors of;

- Assets/Scripts/Keypress.js(11,14): BCE0044: expecting (, found 'OnCollisionEnter'.

- Assets/Scripts/Keypress.js(11,32): BCE0043: Unexpected token: onCollision.

- Assets/Scripts/Keypress.js(11,56): UCE0001: ';' expected. Insert a semicolon at the end.


Yet when I look at how others have done it it's exactly the same as a simple collision. Is there two different collision detection scripts for 2d and 3d development spaces in unity?

Thanks


There are. You need to use the 2D version of OnCollision when using 2D colliders. 

http://docs.unity3d.com/ScriptReference/MonoBehaviour.OnCollisionEnter2D.html

Also you'll get much faster answers if you ask unity-related questions on the unity answers site. Hope you get it to work.

Okay, thank you so so much. I was wondering if it had a 2d counterpart. :) I really appreciate it.

Oh and I'll bare that in mind for next time.