I have a very complex and complicated script.(consist of more scripts actually, but lets focus on this single one)But cut down, I want to activate another public void in another script from this one:
The problem is that, when I run PickMeUp I get a NullRefferenceException error. It apears that I havent defined the PrivatePositionUpdate variable.
public GameObject ThisGameobject;
public Private_position_Update PrivatePositionUpdate;
public GameObject[] obstacles ;
void Awake()
{
obstacles = GameObject.FindGameObjectsWithTag("obstacle");
Debug.Log(obstacles);
}
void PickMeUp()
{
foreach (GameObject _obstacle in obstacles) {
PrivatePositionUpdate = _obstacle.GetComponent<Private_position_Update>();
Destroy(ThisGameobject);
PrivatePositionUpdate.RemoveOfGadget();
}
}
}