Code completion does not work with code-instantiated objects

Godot Version

Godot Engine v4.2.2.stable.official [15073afe3]

Question

image


These lines of code perfectly work, and the script sets the new_star position, but when I try finding this property using Intellisense, I get nothing. This is very inconvenient, especially for noobs like me who are learning GDScript mostly using code completion:
image

You can assign a type to the variable to get most of the auto complete back.

# might error if not type Node2D?
var new_star: Node2D = star.instantiate()

# will be null if not type
var new_star := star.instantiate() as Node2D

Especially helpful used in tandem with class_name

2 Likes

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