- Home /
How to rotate on a single axis.
Hello, I'm new to Unity, and am looking for help.
I have a spaceship. I already have the code to turn it. transform.Rotate(0, direction * Time.deltaTime) but what I don't have, is trying to roll it side to side. When I turn, I also want to the whole ship roll to that side. I already have a script set up to do this. When it is turning left, my variable sideTurn = 15, and when turning right, my variable SideTurn = -15. This does not work with transform.Rotate, because it constantly turns 15 degrees. I want it to slowly rotate towards 15 degrees, and stay there.
I've already done a bunch of research, and all the solutions have just turned my ship either directly down into the ground, or rotated well past 15 degrees.
How about trying animation.(I mean not in a script.I don't know will it right.try it also if you didn't)
Answer by Knoxef · Dec 09, 2020 at 03:10 AM
I have actually fixed this issue myself. The issue being that my mesh was imported incorrectly. Pointing 0, 0, 0 was looking into the ground. What I needed to do was instead of:
transform.localRotation = Quaternion.Euler(0f, 0f, turningAngle);
I did
transform.localRotation = Quaternion.Euler(90f, 0f, turningAngle);
Your answer
![](https://koobas.hobune.stream/wayback/20220613021314im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Changing Y rotation in Editor also changes X and Z? 1 Answer
UI not rotating correctly when in "Canvas mode - Camera", I'm hard stuck on this 0 Answers
How to modify the value of an axis without touching to the others ? 1 Answer
make enemy only follow along the X and Z axis 1 Answer
Smooth rotation about global axis instead of local axis. 1 Answer