Rotating for movement doesn't work quite right

I have a spaceship that moves through space. I want it to tilt one way when moving upwards and tilt the opposite way when moving down.

This doesn’t seem to go quite right. Look at this. The ship in it’s neutral position:


Now I press Down. The ship is now supposed to tilt towards the camera but look what happens:


At this point it’s half way to the next position it’s going to be in and it didn’t even start to flip over yet. When it gets to the bottom things start to get really weird:


The ship starts to tilt away from the camera and then this happens:


It turns completely on the side so you can see the underside of it. From here the angle will keep being weird and it just keeps rotating oddly.
When I move up instead it actually does the same until it reaches it’s destination point in which it starts to rotate towards the screen and then decides to rotate away from the screen in that angle:



Are you trying to rotate as long as a button is held for example, or rotate a set amount when a button is pressed and then rotate back?

The latter

The way I did it for arcade airplane is to have a two bodies used for different part of animation. The root of airplane is invisible sphere object which can only yaw and pitch. To the root I attach airplane fuselage and only fuselage is allowed to bank. By attachment I mean simply parenting fuselage component to the root component in blueprint. This way you avoid all of issues with gimbal lock.

To illustrate it:
So if I want aiplane to gain or drop altitude by banking, then I rotate Root. When it need to turn left or right, I just turn Root by yaw and Fuselage by roll. This way you get illusion that it turns like a real airplane but animation logic doesn’t need to be aware about how pitch and yaw have to handled when you roll object by 90 degrees and get gimbal lock.

But now I see that your problem is most likely not a gimbal lock but the update logic. For Lerp(rotator) to actually work it needs to be called again and again. So your MoveShip even should be called as long as your Timeline should be running.
The next issue is that you are Lerping not from original state to target state but from current state to target state. On every calculation of Lerp, rotation of your actor changes and you are plugin changed rotation as parameter (GetActorRotation->CurrentRotation) into Lerp. Instead, you need to save your default rotation somewhere and use it in Lerp, without overwriting it with each Lerp calculation. I hope it’s clear enough.

I guess I fixed it.


Does it get all wonky if you mash the buttons? Might be something to check as that may be a problem.

You can’t mash the buttons.