-
-
Notifications
You must be signed in to change notification settings - Fork 22k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Godot 4 class_name autocomplete not consistently working when attaching to parent class node despite using static type declarations and only works if "as" keyword is used #82592
Comments
I can confirm this. It completely ignores the type unless there is an "as" keyword. Basic health component class: extends Node
class_name HealthComponent
signal died
@export var max_health: float = 10
var current_health
func _ready():
current_health = max_health
func damage(damage_amount: float):
current_health = max(current_health - damage_amount, 0)
Callable(check_death).call_deferred()
func check_death():
if current_health == 0:
died.emit()
owner.queue_free() and using it in another script like this:
using export like this: @export var health_component: HealthComponent does offer autocomplete. but option 1 should offer autocomplete. |
PS: Code blocks should use triple backticks like this (with an optional language name for syntax highlighting): ```gdscript I edited your post accordingly, but remember to do this in the future 🙂 |
Isn't this related to an older issue about editor suggestions/autocompletion not being consistent? Edit: Here, found the issue #42005 |
ooh! thank you very much! I really hope this gets some attention to get fixed >< |
Godot version
4.1.1
System information
windows 11
Issue description
When registering a type with class_name and using that class name to declare a variable in code only, autocomplete works as expected anywhere in other nodes/scenes. However, if making a custom scene node that extends a script with the class_name, if that custom scene is instantiated in a different scene, even if the type is specified, it only shows the parent node's functions and not any of the extended functionality. I have made a basic project showing the issue
Steps to reproduce
I have made a very simple project showing the issue. https://github.com/mmmmmmmmmmmmmmmmmmmdonuts/godot_4_autocomplete_issue essentially, the extended Node scene will only show the custom function when both the type is specified as well as the type afterwards following "as"
e.g.
@onready var my_class_4: MyClass = $MyClass4 as MyClass
Minimal reproduction project
https://github.com/mmmmmmmmmmmmmmmmmmmdonuts/godot_4_autocomplete_issue
The text was updated successfully, but these errors were encountered: