I moved stuff around, but then I made sure to remake the animation player from scratch yet I’m still getting this error. attempt to call function “play” in base null instance of a null instance.
your anim player cannot be found at runtime (i guess) so cover it on the @onready… something like this…
extends CanvasLayer
@onready var anim_player = $AnimationPlayer
func _ready():
# Debug check to verify if the AnimationPlayer exists
if not anim_player:
print("AnimationPlayer not found!")
print("Available children:", get_children())
func change_scene(target: String) -> void:
if not anim_player:
push_error("AnimationPlayer is null!")
return
anim_player.play("dissolve")
await anim_player.animation_finished
get_tree().change_scene_to_file(target) # Note: In Godot 4.x, use change_scene_to_file
anim_player.play_backwards("dissolve")
ehrm… null is nothing… print out your full tree to see where it resides… maybe you are missing some instantiated scene or so…
func _ready():
# Start from the root of the scene tree
var root = get_tree().root
print_node_tree(root)
func print_node_tree(node: Node, indent: int = 0):
# Create an indentation string based on the current level
var prefix = " ".repeat(indent)
# Print the current node's name and type
print(prefix + node.name + " (" + node.get_class() + ")")
# Recursively print each child node with increased indentation
for child in node.get_children():
print_node_tree(child, indent + 1)