After alot of trying i found out that prefabs dont take Scripts or Gameobjects that are normally draged into the field of the Variable you define.
Now my question is: How can i make it so that a Prefab changes a Variable of another script?
public GameManager GameManager;
void Awake()
{
StartCoroutine("TimeToDeath");
}
IEnumerator TimeToDeath()
{
yield return new WaitForSeconds(3f);
Destroy(gameObject);
yield return new WaitForSeconds(1.5f);
GameManager.currentSprites--;
//This does NOT work since the Prefabs dont take the GameManager object in
}
currentSprites is NOT a variable of the shown script. It is a variable of a script by an empty gameobject that manages alot of variables.
Now, how can i decrese this variable everytime the TimeToDeath() coroutiene is called?
Thanks alot in advance!