I have a project that behaves normally in the Editor mode when I play test it, but when I build it and then test the same project, I get a reference error on a script that doesn’t produce this error in the editor, nor should it produce this error in the build to the best of my knowledge; I’ve included the code I’m using for a reference:
public class JumperInventory : Inventory
{
GameObject player;
private void Awake()
{
player = GameObject.FindGameObjectWithTag("Player");
}
protected override bool AddItemToArray(InventoryItem itemToAdd, int quantity)
{
player.GetComponent<CharacterJump>().NumberOfJumps++;
player.GetComponent<CharacterJump>().NumberOfJumpsLeft++;
Debug.Log("New Jump?");
return base.AddItemToArray(itemToAdd, quantity);
}
}
What I’m trying to do is have this of course increase the number of jumps when it gets picked up, however when I run it in the build it always points to a null reference on the NumberOfJumps and NumberOfJumpsLeft only in the build, in the editor it works fine.
Would anyone know why it would behave differently in the build versus the editor, or provide any insight as to why it has trouble finding reference in the build versus the editor?