Autocomplete does not work for node properties in Godot 4.2, but work in 4.1

Godot Version

4.2

Question

Autocomplete does not work for node properties in Godot 4.2, but work in 4.1.
This can be seen in the images below.
Why is this happening?
Please, help me and sorry for my bad english.

2 Likes

Instead of direct making references to the node name (like $TimerGrenade) in the code, use a variable (Ctrl-drag the node to the editor, if you’re on Windows) that you reference instead. Then type that variable with the node class (for example “as Sprite2D”). That’ll fix the autocompletion, even though you’ll need to restructure your code a bit (but not in a bad way IMO).

2 Likes

For first thank you for your reply.
I have the same issue and what you suggested above is not solved the issue for me.

Everything was fine until 4.2 so it must be some issue with engine or with our editor, i already tried fresh install and still have the issue.

3 Likes

Did you use := to assign the node variable? If you don’t, the type can change at any time and that would not help the auto completion.

It seems likely that there’s a bug introduced somewhere recently regarding direct node names and auto completion , since there has been lots of work with static typing for 4.2.

2 Likes

This is probably the easiest workaround for this issue.

Still was quite surprised when I found this. Probably just a bug that they are working to fix!

If you have a node, named Message, of type Label, instead of using $Message, add a variable near the top of the script as follows:

@onready var message: Label = $Message

This is more robust, because if you change the name of the node then you only need to change a single line of code.

If you are using the Script Editor inside of Godot then set Editor Settings > Text Editor > Add Type Hints to checked to make it easier to work with static types.

2 Likes

this one works for me with external editor (vscode) by assigning the variable like:

@onready var hurt_box := $%HurtBox

Oh guys, they fixed it in 4.2.2 I am satisfied

2 Likes