0 votes

so to have multiple animation, I needed multiple sprites, but for this to work I need only one sprite shown at one time and the rest hidden. This is my attempt (obviously not working). How can I make it so that the code detects if a particular animation is playing and then accordingly hide a show sprites.

func _process(_delta):
    if Input.is_action_just_pressed("LMB"):
        _animation_player.play("jab")
    elif Input.is_action_just_pressed("RMB"):
        _animation_player.play("cross")

func punch_process(_delta):
    if _animation_player.play == false:
        get_node("PlayerJab").set_hidden
        get_node("PlayerCross").set_hidden
    elif _animation_player.play("jab") == true:
        get_node("PlayerJab").set_visible
    elif _animation_player.play("cross") == true:
        get_node("PlayerCross").set_visible
Godot version 3.4
in Engine by (14 points)

1 Answer

0 votes

There is a signal on animation players called finished. You can start a function when that signal is sent with something like this

animation.connect("finished", self, "FunctionWhenAnimationIsDone")

which will start a function once the animation has finished.

by (1,635 points)

Thanks man but I figured out another way of animating which is easier.

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.