Hey guys, I come up with a problem and I tried to resolve it by a numerous ways with no luck that I’m starting to get a bit crazy lol, because I think its a stupid problem.
So my problem is that I’m trying to get a GameObject through FindWithTag, but unity just keekps throwing a Null reference exception! I dont know why, I have the prefab tagged in the editor and have no mispelling errors, and I tried diferent names of tag with no luck aswell.
Here’s me code (part of it):
public class Item: MonoBehaviour {
public GameObject Player;
public bool CanDo = false;
void Awake () {
if (Player == null) {
Player = GameObject.FindWithTag ("PlayerOwner");
}
}
void Update () {
if (Vector3.Distance (Player.transform.position, transform.position) < 5) {
CanDo = true;
}
Hope you guys can help me!
Thanks in advance!