Setget error when running game 2d

Godot Version

3.5

Question

Why I get error can someone give me explaintion and solutions script

You can’t access children nodes until the node is ready. The setter will be called when the node is initialized way before it can access its children. You’ll need to yield() until the node is ready before trying to get_node() the AnimationPlayer

Something like:

func set_animation_type(value):
    animation_type = value
    
    if not is_inside_tree():
        yield(self, "ready")
        
    var anim_player = get_node("AnimationPlayer")
    #...
1 Like