0 votes

If the player holds down the left mouse button, a box is on the screen. If you press T while holding down the right mouse button, an animation plays (the box makes a 360 turn). My only problem is that if I press T and release the left mouse button while the (360 turn) animation is playing, the box stays on the screen after the animation ends. Also the box has an appearing and disappearing animation. The code:

if Input.is_action_just_pressed("left_mouse_button"):
    animation_player.play("appear")


if Input.is_action_just_released("left_mouse_button"):
    animation_player.play("disappear")


if Input.is_action_just_pressed("T") and Input.is_action_pressed("left_mouse_button"):
    animation_player.play("360turn")

Basicly it should be like: the player releases the left mouse button while the animation playing, after the 360 turn animation finished, the disappear animation plays or something like this, couldn't really figure it out.

Godot version v3.3.2
in Engine by (46 points)

1 Answer

0 votes

You could connect the animation player "animation_finished" signal to the box. When the animation player finishes an animation, check if the animation was "360turn". Then, you can check whether or not the left mouse button is pressed and run the disappear animation if necessary.

func on_AnimationPlayer_animation_finished(anim_name:String):
    if anim_name == "360turn" and not Input.is_action_pressed("left_mouse_button"):
        animation_player.play("disappear")
by (18 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 Frequently asked questions and 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 [email protected] with your username.