All Questions

Community

c
Ben curley
posted to: Air movement

Autocompletion issue

As of 3.3 autocompletion of move doesn't happen.

when using var move : = get_parent() 

the autocomplete only recognises it as a State object, by omitting the autotype : 

and with the scene your editing (Player) the autocomplete works for parent node Move, showing moves variables.

  • Nathan Lovato replied

    That's normal, you need the scene to be open for Godot to know which node you're getting. This behavior happens with get_node(), find_node(), get_parent()...

    That's because these functions return the type Node.

    When you open the scene in the editor, Godot checks the node to improve the autocompletion for you.

  • D
    sarver311 replied

    What scene do I need to open to get this to work?  I am having the same issue.

  • c
    Ben curley replied

    Nathan I was reporting that even with the scene open ( Player in this case ) the auto typing  " := " would prevent autocompletion from working. So I removed autotype hinting to allow autocomplete to work. 

    For clarity with Player scene focused, then the following in Godot 3.3 would autocomplete from within the Air.gd script

    get_parent()  would give autocompletion of Move node fields and functions as you rightly say.

    var move := get_parent()   

    The assigned variable move in your video continues to autocomplete in your video but doesn't for me despite having player scene focused, it only offers Node fields and methods.  

    var move = get_parent() 

    By not providing the autotype : the autocompletion contains all of the Move.gd fields and methods.

    I think this is expected behaviour as the method get_parent() returns a Node and so

    var move := get_parent() 

    should lead to move only offering node methods and fields.

    To work round this I can either allow the IDE to determine the var move type from the active scene, by ommiting the type hint " :="  or provide class_name in Move.gd and casting when retriving the parent node.

    My original post was poorly written and not really clear what I was reporting.

  • Nathan Lovato replied

    Okay, sounds like a little bug or regression with the latest Godot version. Because functions like get_node() that have the return type "Node" actually return any type that extends Node.

    You'll see that if you create onready var tween := get_node("Tween"), with the scene open, Godot sees the type is Tween and fully autocompletes it.

    Anyway, hopefully completion will be more reliable in Godot 4, with the new GDScript parser and improve type system.