- Edited
Hey guys, I was working on a 2D game that deals with animation instances. I have only been on Godot for 3 days so forgive me if my code is messy or my question not following some sort of precedent. My problem is that when I create a new instance which contains an AnimationPlayer as a child, the AnimationPlayer simply does not work for the instance, but does for the original copy. I've tried scouring the internet for hours, but nothing has come of it. I'll link some example code.
extends Area2D
func _ready():
->set_visible(true)
->set_collision_layer_value(1, true)
func _on_body_entered(_body):
->print("Fired")
->$ChildAnimator.play("Animation")
->await get_tree().create_timer(1.0).timeout
->set_visible(false)
->set_collision_layer_value(1, false)
->print("Registered")
->queue_free()
And the tree looks like this
\/ Area2D(Script)
|--AreaCollider(CollisionShape2D)(NoScript)
|--Texture(Sprite2D)(NoScript)
|__ChildAnimator(AnimationPlayer)(NoScript)
As far as the code goes, whenever I go into testing and a physics body collides with the Area2D, both of the print statements are activated, but i can tell by the frequency that the await get_tree().create_timer(1.0).timeout
and queue_free()
lines are also nonfunctioning, which makes me think the problem has to do with the tree somehow, even though the Texture(Sprite2D) is working fine. For the record, I've tried moving the script to the AnimationPlayer, Setting the specific animation to unique using the animation manager, I've restarted Godot multiple times. I am really at a loss for what to do, any help would be greatly appreciated.