Hi. I’m using a GameObject called References, containing a script with the same name, which contains references to other GameObjects which are activated and deactivated during gameplay. Now, I’m having problems with referencing the static variables within the References script. The error I get is:
Assets/Scripts/CharacterSelection.cs(43,87):
error CS0176: Static member
`References.playerRef’ cannot be
accessed with an instance reference,
qualify it with a type name instead
and the erratic code looks like so:
private GameObject playerRef;
void Start () {
playerRef = GameObject.Find ("References").GetComponent<References>().playerRef;
}
The References script looks like this (the value of the variable is assigned elsewhere):
public static GameObject playerRef;
I’ve been googling for help on static variables, but all I can find is how to work with static methods. If anybody could give me a pointer on what I’m doing wrong, it would be really helpful.