I have the “HQ” script, and some instantiated prefabs (tiles) that all have the script “tile” attached to it. Now I want to alter the variable “test” in one specific object.
HQ script
...
//variable target holds one of the instantiated prefabs
tile targetScript = target.GetComponent<tile>() as tile;
targetScript.test = 1;
...
tile script
...
public static int test;
...
The error: “Static member `tile.test’ cannot be accessed with an instance reference, qualify it with a type name instead”.
It’s drving me mad, I already found some topics on using GetComponent, tried different ways to get rid of the error, but no success. Is there no easy way to just tell Unity: “I want to alter variable X in script Y of gameobject Z”? Maybe somebody could give me a hint on how to solve that problem.
Thanks in advance,
Thomas