Error calling method from signal 'animations_finished'

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

I have a simple enemy script where the enemy follows the player and the player can damage the enemy. I was recently trying to add a death effect with animation to the enemy. I did that and everything works fine except that I get an error-message like every half-second.
The error message is as following:

emit_signal: Error calling method from signal ‘animation_finished’: ‘KinematicBody2D(’: Method not found…

This is the enemy script:

extends KinematicBody2D

const GRAVITY = 10
const UP = Vector2(0, -1)

var motion = Vector2()
var is_dead = false

onready var animsprite = $AnimatedSprite
onready var player = get_parent().get_node("Player")
onready var stats = $Stats

func _physics_process(delta):
motion.x = clamp(motion.x, -stats.speed, stats.speed)

if is_dead == false:
	if player.position.x > position.x:
		motion.x = stats.acceleration"Skeleton_Walk")
		animsprite.scale.x = 1
	elif player.position.x < position.x:
		motion.x = -stats.acceleration"Skeleton_Walk")
		animsprite.scale.x = -1
		motion.x = lerp(motion.x, 0,0.2)"Skeleton_Idle")

motion.y += GRAVITY

motion = move_and_slide(motion, UP)

func _on_Hurtbox_area_entered(area): -= area.damage

func _on_Stats_no_health():
motion.x = 0
is_dead = true"Skeleton_Death")
yield(animsprite, "animation_finished")

Im sure the problem has something to do with the “_on_Stats_no_health():” function and the “if is_dead == false:” statement because I didn’t get the error message before I added that “if” statement, but then the idle animation would play instead of the death animation when the enemy dies.

I feel like I am missing something simple. Any help is appreciated!

:bust_in_silhouette: Reply From: Wakatta

Looks to me like you changed the name of a function connected by a signal(animation_finished) from the AnimationPlayer and now Godot’s going bananas looking for it.

Simply change the node signal connection to the appropriate function or remove the connection

Wow that was it. Seems like I hade forgotten to disconnect the signal from the animatedsprite to the enemy script. Thank you very much!

LyguN | 2021-01-31 23:54

Not a problem.
When i first started had a lot of trouble remembering what signals were connected to where and it became a nightmare to manage the more my project grew.

That’s why i do all my signal connections through code now. You live you learn

Wakatta | 2021-02-01 00:04