Help on the “How to make a game” tutorial playlist

Updated on February 12, 2020 in General
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
4 on February 9, 2020

I’m getting this error code when I pass the end game object I have no clue what I did wrong

NullReferenceException: Object reference not set to an instance of an object
EndTrigger.OnTriggerEnter () (at Assets/Scripts/EndTrigger.cs:9)

Here is my script

EndTrigger.cs

using UnityEngine;

public class EndTrigger : MonoBehaviour
{
public GameManager gameManager;

void OnTriggerEnter()
{
gameManager.CompleteLevel();
}
}

  • Liked by
Reply
0 on February 9, 2020

I’m currently on (EO9)

  • Liked by
Reply
Cancel
2 on February 10, 2020

Did you set a reference to gameManager in the editor?

Also, OnTriggerEnter needs a collider argument.

on February 12, 2020

I did what you said and it gave me progress but now when I start the game the animation automatically says level complete

Wise
on February 12, 2020

I don’t know what that means. I haven’t watched the tutorial you’re referring to. Could you post the code that would be causing this?

And if it’s an animation, is it set to just play automatically?

Show more replies
  • Liked by
Reply
Cancel