AnimationPlayer signals not returning anything to output.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Aby_is_a_kitkat

ok, so I’m trying to learn how to use signals in general but I’m also trying to use them with the animation player. but ever time a make a signal it will not returns anything to the output window. I’m not exactly sure what the problem is here is an example of what I’m attempting.

extends KinematicBody2D

func _ready():


func _on_AnimationPlayer_animation_changed(old_name, new_name):
   print(old_name,"_animation_changed_to_", new_name)

func _on_AnimationPlayer_animation_finished(anim_name):
:bust_in_silhouette: Reply From: p7f

As you are extending a KinematicBody2D, when using connect, you are trying to connect the signal “animation_changed” from the KinematicBody2D, which does not have that signal. I guess you have an animation player Node theere as a child of the KinematicBody2d, so you should do something similar to:


Remember, the connect function should be called from the objects that has that signal. See the docs for better reference. You could also connect them from the editor to avoid that lines of code if you wish.

I’m afraid I don’t understand what you mean. dose the signal’s function have to be on the node emitting the signal? or dose the signal function you get when you connect a signal true the node tab not count as a receiver?.

Aby_is_a_kitkat | 2020-07-30 19:02

Hi, i don’t understand your question. The function which recieves the signal can be in any script attached to a node. But when you make the connection, the syntax is <Singal emmiter>.connect("signal name", <signal reciever>, "function to connect to")

In your case, you are trying to connect a signal being emited on an AnimationPlayer2D, to a function on a KinematicBody2D, and you are doing the connection in the KinematicBody2D script. So instead of:


You should do


(I’m assuming your animation player node is direct child of your kinematic, and is called AnimationPlayer here)

So, whenever an animation finished, AnimationPlayer node will emit automatically the signal animation_finished and if its correctly connected to your function, then the function will get executed.

The code you gave, uses connect directly on an script that extends KinematicBody2D, but that node does not have those signals.

If you connected the animation player’s signal from the editor in the node tab, then you shouldnt need those connect instructions.

p7f | 2020-07-30 19:09