Problem with get_animation_names() in tutorial

Godot Version

4.4.1

Question

Hello, I’ve got an inconvenient issue related to the tutorial with get_animation_names() method. To be clear with code hinting.

In the moment to of typing:

$AnimatedSprite2D.sprite_frames.

nothing is suggested by the editor. Moreover, I can jump to the docs of sprite_frames type, but there I can’t find the mentioned method that confuses me as a developer who tried to learn the provided API.

If I typed get_animation_names() manually - the godot recognizes it, but not allow to jump to docs to see.

How can I manage the hint issue? Could you assist me with it?

P.S. the question was asked in the Archived topic here:
similar topic
Since no reaction for more than 2 days, I’ve decided to create a new topic

Short answer: Godot GDScript autocomplete sucks. In all kinds of situations.

Good news: you shouldn’t do that anyway. You should create a typed variable (ctrl-drag the node from tree to script) from the node and use the variable instead. Then it works.

1 Like

For auto-hint to work it is best get reference to object you want to use in beginning of script.
Something like this:

@onready var my_frames : SpriteFrames = $Sprite/AnimatedSprite2D.sprite_frames

Correct node type or class must be provided.
After that in your runtime code you can use my_frames.get_animation_names().
Hinting and help will work.

Excellent! Expliciting the type works perfectly!

Thanks a lot @makaboi & @lillycherry!

1 Like