Topic was automatically imported from the old Question2Answer platform.
Asked By
Erto
Hi! Thank you for trying to help. i think you mean this .
func _on_anima_animation_finished():
if $anim/anima.animation == “SWORD1”:
canSlash = false
And now I have discovered that there is a error in here:
E 0:00:48.777 emitsignal: Error calling method from signal ‘animationfinished’: ‘KinematicBody2D(KinematicBody2D.gd)::onanimaanimationfinished’: Method expected 0 arguments, but called with 1…
I think the problem could be that I am using animation player and sprite. The tutorial i based this on was using animated sprite.
“E 0:00:48.777 emitsignal: Error calling method from signal ‘animationfinished’:”
Is stating that when the signal animationfinished is emitted, the connected function onanimaanimationfinished is having trouble being called.
The next line in the error message explains why “‘KinematicBody2D(KinematicBody2D.gd)::onanimaanimationfinished’: Method expected 0 arguments, but called with 1…” states that your function onanimaanimationfinished is being called with 1 argument (the signal emitted an argument) but your function is expecting 0 arguments.
If you look at your code, this is exactly the case.
Solution
Change func onanimaanimationfinished(): to func onanimaanimationfinished(arg1):. I imagine arg1 is the name of the animation that finished
Hi. Thanks for your help!
But it still doest work
THE ERROR: Invalid get index ‘animation’ (on base: ‘AnimationPlayer’).
Then i tried using currentanimation as It seems the AnimationPlayers “animation”.
I dint get any errors while using current animation but It still didnt solve my problem. I still couldnt move after using the sword animation. I could only press the sword attack again. Does this mean the problem is somewhere else? I feel like i have read the code over million times already from the tutorial and it seems the same.
Erto | 2023-05-22 19:07
There error here is that ‘AnimationPlayer’ (your node called $anime/anima) doesn’t have a member called animaton. If your goal here is to deny slashing if the animation named "SWORD1" finished, then instead try using the below code:
func _on_anima_animation_finisedh(animeName):
if animeName == "SWORD1":
canSlash=false