0 votes

Hello, I am making a game and imported a rigged model from blender. It has multiple animations under one animation player node. I wanted to ask, how should I play each animation from that one node when I click a certain keyboard key?

in Engine by (21 points)

1 Answer

0 votes

Assuming you attach a script to the animationPlayer's node

func _input(event):
    if event is InputEventKey: #if a keyboard key is pressed
        if event.is_pressed(): #if the key is pressed
            if event.scancode == KEY_SPACE: #the space is pressed
                play("name_of_first_animation")
            elif event.scancode == KEY_C: #the c key is pressed
                play("name_of_second_animation")

if you attach the scrip to a parent node then it will be $AnimationPlayer.play("myanimation")

by (4,982 points)
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 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 webmaster@godotengine.org with your username.