Primitiveman495 ok, so:
the function is connected
print("fired")
writes a message
but animation player doesn't play, that is not what's strange, because it could be a million things ( and it was fine as children of Area2D
, don't change that)
the fact that the node doesn't selfdestruct with queue_free()
is what's weird.
My theory: It could be something to do with signals or collisions preventing the node from being terminated. Could be that the node is sending a signal to itself and that's why it doesn't work?
Try moving the script to a Node2D so that it looks like this:
Node2D (script)
|
Goal(Area2D)
|
Collider
Sprite
AnimationPlayer
disconnect the signal, then change the structure, then
connect the Area2D again but with the script in Node2D
you can create a Node2D anywhere and right_click to turn it into the scene root
the script would then detect a collision in Area2D
but destroy the parent node Node2D
.
IF the problem is with queue_free()
. It could also be a problem with the animationplayer
s preventing the node from selfdestructing because they are somehow altering a sprite in a different scene??? I'm not very familiar with 2D.
But try using an AnimatedSprite2D instead of a sprite2D
with AnimationPlayer
, it lets you create different animations and play them, all in the same node. Maybe that will fix it.
Or not? AnimatedSprite2D lets your create animations with sprites, AnimationPlayer allows you to change other properties like scale and rotation. So if you are only using spritesheets use an animatedsprite2D, otherwise... the sprite2D with animationplayer should work.
Is there MORE code in your scripts that is doing something else?