Global is throwing parser errors everytime I use it, what am I doing wrong?

Godot Version

4.2.1

Question

The issue I am running into is I am not sure how to remove the parser error now :face_exhaling:
I have been following along with a guide, both written and video format and the code I have entered doesn’t seem to work at all! The guide is based on 4.1 and I am using 4.2.1 and I am getting errors that the presenter is not getting when I try to use any lines containing “Global”.
examples:
if Global.player.velocity.length() == 0.0:
This returns: “Line 8: Identifier “Global” not declared in the current scope.”

I am not sure what I did wrong as I have a Global_Settings.gd with variables set up. I haven’t seen anything related to this being different between versions though.

I discovered this is the reason why my @export variables are not working thanks to another user here so now that that is cleared up I am still unable to run my game because this error crashes the preview when I attempt to run the project.
Sorry if this is too much nonsense, I am still very new.

So your extending State class

the error says “function signature doesn’t match the parent.”
“Parent signature is”: func update() -> void:

your function signature is: func update(delta)

you need to either conform to the parent class signature or, modify the parent class signature to match WalkingPlayerState, or choose a different function name for the class.

Error checking typically breaks down after the first error it sees. I bet if you fix the signature error, the other will clear itself.

1 Like

EDIT:
I am a complete idiot. I had the autoload name as “global” not “Global” (capitalized)
image

it works, and I feel STUPID lol :clown_face:

OLD IDIOT COMMENT:

THANK YOU!
one hitch, I resolved that line error by changing the parent in the state.gd script to match, but the “Global” issue remains.


Output is just saying it isn’t declared anywhere.
It is my understanding “Global” is just… global? I did not think it needs declaration.

1 Like

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