–1 vote

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):
in Engine by (19 points)

1 Answer

0 votes

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.

by (3,493 points)

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?.

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.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.