NullReferenceException: Object reference not set to an instance of an object PlayerEndCollision.OnCo

No Idea why this code isn’t working. Please help.

This is one script,

using UnityEngine;

public class PlayerEndCollision : MonoBehaviour
{
    public GameManager gameManager;
    public void OnCollisionEnter2D(Collision2D collisionInfo)
    {
        if (collisionInfo.collider.name == "Goal")
        {
            gameManager.CompleteLevel();
        }
    }
}

And this is part of another

 public void CompleteLevel()
    {
        Debug.Log("Level Won");
    }

Any Help is appreciated.

Since you didn’t copy the exact error which includes the error line, my guess is gameManager is null.

How to fix a NullReferenceException in Unity3D:

http://plbm.com/?p=221