Help - Using autoload to transfer variables in a scene

Version

Using Godot 4.2.1 through steam.

Question

Hi. New to Godot here. I’m making a 3d platformer with various abilities, a dash, jump, sprint etc. I have several different levels as scenes, and a main menu to connect them. I want it so that once the player beats the level, they unlock an upgrade depending on the beaten level, so I made an Autoload script with the variables for all of the upgrades and tried to connect them to the player, but it doesn’t seem to be working. Can provide materials and code if needed, thanks.

Variable in a node
@export var dash = false

Player code
@onready var dash = get_node(“Node”)

All variables seem to be null, or just don’t work

It looks like you are not using any autoload in the code that you provided. Do you have more examples where you use the autoload?

Here is a tutorial on how to use autoloads: Singletons (Autoload) — Godot Engine (stable) documentation in English

image

I’m unsure of how to use autoload, but I was following a tutorial, and unless that section was skipped, I’ve followed it exactly

In the screenshot you showed that your autoload is called Autoload, so you should be able to access any variable in its script with:

Autoload.dash

No matter in what other script you are working. For example in the player code:

func _ready():
	print(Autoload.dash)
1 Like

Invalid get index ‘hyper_jump’ (on base: ‘Node (autoload.gd)’).

Probably means I haven’t set it up.

Nevermind, it worked,

Thank you so much!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.