OnColliderEnter2D not working!

Hello again,

i got a problem with the OnColliderEnter2D, because if my character hits the Ground tagged with “Grass” the function OnCollider2D is not called. This is a problem because now my character only jumps 1 time.

Here is my code:

var moveSpeed = 4f;

// Jump of Player
var jumpHeight : float = 500;
var isJumping : boolean = false;
var nextTimetoJump : float;

function Update () {
	 Movement ();  

function Movement () {
	if(Input.GetKey (KeyCode.D))
		transform.Translate(Vector2.right * moveSpeed * Time.deltaTime);
	if (Input.GetKey(KeyCode.A))
		transform.Translate(-Vector2.right * moveSpeed * Time.deltaTime);
		if(isJumping == false){
		rigidbody2D.AddForce(Vector2.up * jumpHeight);
		isJumping = true;

function OnCollisionEnter2D (coll: Collision2D)
	if(coll.collider.tag == "Gass")
		isJumping = false;

I am using the latest version of Unity

I hope somebody is able to help me :s

Greetings GreenTee.

I know this is an old question, but I have a suggestion that has helped me greatly. I suggest creating a script called “Tags” and make some public constants containing the name of your tags. For example:

public class Tags
    public const string GRASS = "Grass"
    public const string PLAYER = "Player";

Now you could instead check the tag as:

if(coll.collider.tag == Tags.GRASS) { }

Whenever you add a new tag, also add it to your Tags class, and you’ll never have to worry about spelling again. Better to do it this way, as opposed to hard coding those values in each script.

replace the following code :

if(coll.collider.tag == “Gass”)


if(coll.collider.tag == “Grass”)

Amazing that i am so stupid! I really have to watch at my spelling! Thanks!!