Script Error: OnCollisionEnter2D

Hello,

I’m having the weirdest problem in Unity 5.4.1f1

I have a 2 2D sprite which fall one onto another. Both have Rigidbody 2D & Box Collider 2D. On of them has the following script attached:

using UnityEngine;
using System.Collections;

public class TestScript : MonoBehaviour
{

    // Use this for initialization
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {

    }

    void OnCollisionEnter2D(Collision2D col)
    {
        Debug.Log("TEST");
    }

}

When compiling in VS - No errors appear. Unity, however, shows this message in the console:

Script error: OnCollisionEnter2D This
message parameter has to be of type:
The message will be ignored.

And sure enough - The function isn’t being called.

When I double click the error it takes me to the OnCollisionEnter2D function, but I don’t know what need I do to fix it.
Can anyone see what’s the problem here?

Thanks
Nitay

The code seems fine to me.

  1. Make sure that in code you use
    “Collision2D col” as a parameter for
    a method, but not “Collider2D”.

  2. Try to close Unity and VS. Then open
    them again.