The easiest way is to create a singleton
script. The items in that script can be directly accessed from other scripts.
- Create the script with the "global" variables
- Save it (for example, assume it's called
Globals.gd
)
- Project | Project Settings | AutoLoad (tab)
- Add the script to the list (ensure
Singleton
is checked)
Now, to access anything in it (say a playerSpeed
variable), just preface the reference with the script name. For example:
var mySpeed = Globals.playerSpeed
Also, note you can have multiple singleton scripts if you want.