#I'm unable to `find_child` on a Node that was created during the `_ready` method call

1 messages · Page 1 of 1 (latest)

stark cipher
#

Could someone please help me understand why I'm not able to find_child on the passed target: Node

func _init_healing_abilities(parent_node: Node) -> void:
    var healing_abilities_timers_node_group = Node.new()
    healing_abilities_timers_node_group.name = "AbilityTimers"
    parent_node.add_child(healing_abilities_timers_node_group)


func _heal_to_full_after_time(target: Node, wait_time: int, one_shot: bool) -> void:
    print(target)
    print(target.find_child("AbilityTimers"))

The two functions are being called by the same script and they both pass in self
I'm betting it's something small and silly, but this feels like it should be possible..

jade badger
#

It seems that, by default, find_node only looks for nodes that have an owner. Nodes are automatically assigned owners when created through the Godot interface, but the same does not apply for nodes created through .new().

Replace your invocation with find_child("AbilityTimers", true, false)