Still no idea what I'm doing wrong

I’m using Godot version 4.4. I think a few weeks ago, I posted on the forum to get some help and got some nice advice, but I looked at tutorials and even a sample of lines of code provided to me for the basic idea, but I just can’t get my animation to play. Any ideas why?

$AnimationPlayer is a reference to a child node named “AnimationPlayer”. But since this script seems to be on the AnimationPlayer itself, you have to call play("Eyelids") directly, without a reference to another node. (Same goes for play_backwards("Eyelids") or any other function of the AnimationPlayer class.)

1 Like

If this script is attached your AnimationPlayer then it doesn’t have a child so $AnimationPlayer doesn’t work, instead you could use self.play or just play.

You declare the function Eyelids but I do not know if you ever use it, maybe you mean to use the _input function which is called automatically for every input event

func _input(event: InputEvent) -> void:
    if event is InputEventKey:
        if event.keycode == KEY_SPACE:
            if event.pressed:
                play("Eyelids")
            else:
                play_backwards("Eyelids")

Make sure to paste code instead of screen shots

3 Likes

Thanks a lot! But do you know how to stop the animation from looping once the input is pressed?

Maybe it’s an echo event, like when you hold a key down and it goessssssssssssss

func _input(event: InputEvent) -> void:
    if event.is_echo():
        return # skip echos

    if event is InputEventKey:
        if event.keycode == KEY_SPACE:
            if event.pressed:
                play("Eyelids")
            else:
                play_backwards("Eyelids")
3 Likes

Again, thank you so much!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.