I have a simple scene, which inherits from Node2D and contains an Animation Player and a Sprite2D:
Then in the following script the variable animation_player, which should work fine, is NULL:
extends Node2D
class_name PickUpEffect
@onready var animation_player = $AnimationPlayer
func start_pick_up_effect() -> void:
animation_player.play("idle")
func _on_animation_ends() -> void:
queue_free()
What am I doing wrong?