+1 vote

This is a weird one.

While using states and animation tree, I can't seem to jump and attack at the same time. I just can't figure out why.

When I use Animation Player, on the other hand, it works fine. I'm having to use both the state and the player at the same time which causes jitters in the animation.

This is the animation tree that I have:

animation tree

and the code I'm using:

if is_on_floor():
    if x_input == 0:
        motion.x = lerp(motion.x, 0, FRICTION * delta)

    if Input.is_action_just_pressed("ui_up"):
        motion.y = JUMP_STRENGTH


in Engine by (27 points)

1 Answer

+1 vote

I'd recommend you to use Advance Conditions instead of travel function, this will allow you to check the state machine functionality in the editor and setting the variables in your code is straightforward.
In this video you can see how jumping attack is implemented using Advance Conditions.

by (1,002 points)

Thanks for the lead. I spent the entire day implementing this but the issue is still there. I did find the video very informative and adapted a lot of it into my project but sadly now I'm juggling between this implementation and the animationplayer.play() just for attack since I can't switch to attack while in the air.

I think it could be how I've programmed for the jump and I think that fall animation while in air overrides all other instructions. (I've set the animation to !is_on_floor())

I'm a total beginner and I've drifted off a lot from the multiple tutorials I saw and I can't figure out what to check.

there is no one "correct" way to do things, there are multiple options and you will find what fits better with trial and error.
For example, you can have 2 state machines inside a blend tree, one for air and one for land, using a transition to switch between them. Later tou can add more (on water, on vehicle, etc.)

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.