How to interrupt animation then reverse back to idle state

I prototyped a hover ship driving game and am now animating the ship movement. When the ship is idle it hovers up and down (see video below). When I press left or right on the keyboard an animation is triggers and the ship tilts left or right.

The problem is that the tilting animation always plays to completion. If I release left or right, I want the animation to be interrupted, and the ship to tilt back to the idle hover state.

Can someone advise me on how to interrupt an animation and reverse it back to the idle state?

Hey @TheCosmicAC0!

So for this you’re going to want to use a state machine. Not an overly complex one, but one nonetheless. Then you’ll blend in and out of your various animations :slight_smile:
If you need a tutorial, there’s a quick start for animations, and tons of material available for it, but it probably won’t be labeled “state machine tutorial”, it’ll just be a part of pretty much every gameplay animating tutorial :slight_smile:

Thanks @Mind-Brain ! That was super helpful.

After some experimentation I decided that a more desirable approach would be to apply rotations or translations in real time, in response to player input. For example, if a player pushes right on the joystick the ship would tilt to the right. The tilting would be in proportion to the length of time that the player pushes the joystick to the right.

Can you suggest the best approach to control skeletal mesh bones to achieve something like what I described?

Glad you liked it, @TheCosmicAC0!

So let’s see. How about… hmm… That’s a stumper. I saw a post a while back that was a code snippet for resident evil tank movement. That could be useful for this as inspiration! Let me go find it and I’ll get back to you on this same entry!

@Mind-Brain one approach is to use a Poseable Mesh Component, and associate it with a Skeletal Mesh. The Poseable Mesh component then allows use of the Get Bone Rotation and Set Bone Rotation nodes so the bone orientation can be get/set directly in a Blueprint.

This works well for me, but I would still prefer to use proper animation logic in an Animation Blueprint. If you find any insights from the RE tank controls post, or any other source, that would be awesome!

@TheCosmicAC0

Here you go! It’s pretty fresh, it was posted the 23rd!

seems like using an aim offset type of blendspace would work. You just make a static pose for the extremes, then stick deflection can be the input.

If your ship doesnt transform or change the position of the verticies in some sort of animated way. There likely isn’t any good reason to make it a skeletal mesh in the first place.

The engine is incredibly bad at physics (particularly skeltal ones), so that’s definitely a reason to avoid skm also.

Skm is also a pain to light correctly, so that’s count 2 of not using it unless you have to.

If you are looking to animate parts - say the tail of a plane for instance, the best way is to have separate parts, and change their rotation on a single axis.

How, how much, etc, thats all depending on how you want the player controller to handle things / and or, how you process input on the thing itself.

I can’t say I have seen any good examples of this as a public tutorial unfortunately.

Btw,
a pro skm reason cold be 1 draw call over several.
Unfortunately, thats really the only real benefit I can think of when dealing with non organics…