Problem with accessing global variables

I have a script called Game_Manager, where I declare a global variable: static var walk_speed = 0;
And then access it like this from other scripts: print (Game_Manager.walk_speed);

My problem is I can access it from one script with no problem, but from the next script I need to access if from I just get an “Unknown identifier: Game_Manager” error. I’m accessing it exactly the same in both scripts (even copy/pasted to be sure).

Game_Manager is parented to an empty game object. The two scripts that need to access it are a script called Character_Control that is parented to my character, and a script called MouseOrbit that is parented to my camera (the latter being the one that doesn’t work).

Anyone know why?

Hmmm… it seems to have something to do with where my scripts are located in the file system. While moving them around in the project view I did get it to work at one point, but then I broke again and I can’t remember what I did to make it work :stuck_out_tongue: . I’m afraid I don’t quite understand the rules and restrictions regarding accessing global variables and so far I haven’t been able to find anything in any of the documentation that explains it.

See advanced topic - compilation order

Generally as a “basic rule of thumb” (the docs contain it in more detail etc)

Plugins folder is compiled first
Then Standard Assets and Pro Assets
Then the rest

files in folders further up can not access files further down

Ah, thanks!

EDIT: Yeah, that was very helpful. I’ve got it all working now :slight_smile: