CardScene.Instantiate() as Card;
and
new Card()
What is the difference between them?
Why do I encounter the error of node not being found when using 'newCard()'
Does anyone know? Please answer me, thank you
https://docs.godotengine.org/en/stable/classes/class_packedscene.html#class-packedscene-method-instantiate
https://docs.godotengine.org/en/stable/classes/class_gdscript.html#class-gdscript-method-new
This would imply you're searching the SceneTree for the instanced node - you must add it to the tree for it to exist in the tree, e.g. by calling add_child
on an existing node (where the engine will then call _ready
).
Downandout More precisely, the 'new' method does not trigger the _Ready() method
https://docs.godotengine.org/en/stable/classes/class_packedscene.html#class-packedscene-method-instantiate
https://docs.godotengine.org/en/stable/classes/class_gdscript.html#class-gdscript-method-new
This would imply you're searching the SceneTree for the instanced node - you must add it to the tree for it to exist in the tree, e.g. by calling add_child
on an existing node (where the engine will then call _ready
).
Mealy thank you
© 2022 - 2024 — McMap. All rights reserved.