Animation tree Jump and Attack

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By whoisda

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

else:

	stateMachine.travel("Jump")
:bust_in_silhouette: Reply From: davidoc

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.

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.

whoisda | 2020-03-24 17:22

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.)

davidoc | 2020-03-25 04:52