I m trying to acces gamemanger function via : `else if(col.tag == "Arrow") { FindObjectOfType().EndGame();
}`
and every time show me the error : Object reference not set to an instance of an object Arrow.OnTriggerEnter2D (UnityEngine.Collider2D col) (at Assets/Scripts/Arrow.cs:38)
How can i fix it?
Here is the GameManager code :
using System.Collections;
using System.Collections.Generic; using UnityEngine;
public class GameManager : MonoBehaviour {
private bool gameHasEnded = false;
public Circle circle;
public Spawner spawner;
public void EndGame()
{
if (gameHasEnded)
return;
circle.enabled = false;
spawner.enabled = false;
gameHasEnded = true;
}
}