Download

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:

629b39b5c7.jpg

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

89b007fdd8.jpg

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:

8b6557906e.jpg

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

0c5aa277be.jpg

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:

2af4a822f1dda36e43e2542bcd0090ee6edc2a1b.jpeg

19e879bba36c098a12b9bef83a648744bd62d4d0.jpeg6f96e7224f3fda0d49e36239825c55ea923a7060.jpeg5d9e0cafc9a6be4991ae8cd5c98760978a8dd808.png2bb555d9c26650c377a3c9a077731743bb8f659c.png

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:
AirplaneHierarchy.JPG
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.

f9959f3f2d.jpgdf95d531ea8207bd9750cd429ef88c8d42169d52.jpeg

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.