Hey guys.
I am currently trying to build some basic spaceshipmovement (and its progressing very well) but now I have encountered a problem. When the spaceship tilts up more and more it reaches a point when it just magically snaps to 90/270 degrees on the x-axis (at 87 and 273 degrees it snaps) and gets stuck there. I have allread read something about this and that this is a unity-problem but this looping like turn is pretty important for moving in 3D space (in this case really “space” because its a spaceship ) so limiting the rotation to 87 or 273 degrees is no option(I would not like to :(). Do you have a clue how to get this right?
First, I’m pretty confident that it’s not “a Unity problem”. Based on your explanation, it sound like gimbal lock. You’ll probably need to post the code you’re using for rotation before you’ll get any useful help.
Here is also one picture of the ship, its transform and the desiredxrotation variable and how they act:
Picture one is just normal. “Show” is just for me to indicate the desiredxrot. I have touched nothing now.
Picture two shows what happens if I hit the up or down button. It just jumps to a high value but it shouldnt. This makes the rotation bumb around at 360°x.
Picture 3 is what happens if I get to 270 and the ship gets stuck there. As you can see it does not move to its desired rotation either…
Even if xangle=0 the Lerped xangle is around 0.1. Problem #1. #2 is that if I now push a button for turnig up or down the xangle value jumps to 3.01 or -3.01. The snaping at 90 and 270 degrees z is propably be the same problem because i I have done it with Mathf.Lerp too. Anyone knows how to fix this?
I don’t know where this line is wrong even if I look at the documentary.
I want this line to Lerp the xangle (x rotation) from the actual x angle to the desired rotation I assign in the Up Down function. So I want to turn/rotate the ship smoothly with accelerating and descceleration when it reaches it’s desired rotation. That’s the best way I found but if there is a better method please tell me.