Hi guys,
i instantiate a gameObject every few seconds. In the attached script i want to use a variable from a Gameobject (which is not a prefab). This means, the variables should be the same in every created clone.
How to Access the variable?
Script which is attached to prefab:
public GameController gameController;
void Update()
{
float variable = gameController.gameSpeed;
}
Script attached to gameObject:
public float gameSpeed;
void Update ()
{
gameSpeed = gameSpeed + 0.1f;
}
Normally i attach the Gameobject to the prefab in the Inspector, but it is not even possible.
So what am i doing wrong here?