My game is working fine during my test in the Unity Editor.
After building the apk and installing on my phone, I am getting :
NullReferenceException: Object reference not set to an instance of an object
It seems that the GameObject.FindGameObjectWithTag was not able to get the “Player” tag. Im not quite sure as I am just new to Unity and game development.
Below is my code including the Debug.Log from Unity Console and ADB. Appreciate the help
void Start()
{
player = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerMovement>();
isGameStarted = false;
IsDead = false;
Debug.Log(player);
}
Console:
Player (PlayerMovement)
UnityEngine.Debug:Log(Object)
GameManager:Start() (at Assets/Scripts/GameManager.cs:67)
ADB:
12-08 00:30:32.054 2226 6891 I Unity : Null
12-08 00:30:32.054 2226 6891 I Unity : (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
12-08 00:30:32.054 2226 6891 I Unity :
12-08 00:30:32.347 2226 6891 E Unity : NullReferenceException: Object reference not set to an instance of an object
12-08 00:30:32.347 2226 6891 E Unity : at GameManager.Start () [0x0003a] in <0eceeb3a1845417d9269f1499c75c894>:0
12-08 00:30:32.347 2226 6891 E Unity :
12-08 00:30:32.347 2226 6891 E Unity : (Filename: <0eceeb3a1845417d9269f1499c75c894> Line: 0)
12-08 00:30:32.347 2226 6891 E Unity :