- Home /
How to rotate ship smoothly?
Hello, I'm trying to find the best way to rotate my ship when it turns. What I want the ship to do is to rotate X a ittle to the left, when the ship is turning left and vice versa :)
The way that i'm rotating the ship is by this line of code:
transform.Rotate(new Vector3(0,RotAngle,0));
RotAngle is basically just the value that is added every FixedUpdate frame
and movement this is the movement
rigidbody.AddForce(transform.forward * speed);
Thanks, Andreas :)
Posting your movement code will help with an accurate answer.
Answer by chillersanim · Jul 04, 2013 at 08:41 AM
You can either use forces (with addTorque), what gives a physical behaviour, but when you don't want to use physics, there are other possibilitys.
You can use lerp (from mathf for values or from vector3 or from quaternion depending on what you use). The first two overload variables are start and target, the third overload variable needs to be a value between 0…1 which determines where between the start and the target your value will be.
As an example:
var a = mathf.lerp(0.0f, 2.0f, 0.5f); The var a would now be 1.0f.
But when you use:
a = mathf.lerp(a, 1.0f, Time.deltaTime * multiplicator);
It woud be smoothed out with the time.
As multiplicator you can use any value you want. It is like the sensitivity.
Hope I was able to help
Greetings
Chillersanim
Answer by Fixet · Jul 03, 2013 at 05:08 PM
you could probably use the Third Person Controller and that might help. You can just set the ship as the character and then set the camera to your camera, then after that you can put the rotation speed down in the controller. Reply to me if that helps.
I have made the ship control-facillities, I'm just looking for a way to rotate the ship a little, so that it looks realistic :-)
Your answer
Follow this Question
Related Questions
How can i rotate the aircraft elevator around the yellow axis up and down ?? as shown in the pic 0 Answers
How to reset child object's rotation without changing parent's 1 Answer
UnityException: Input Axis Rotate is not setup. 2 Answers
Rotate object on the Y axis 90 degrees every 5 minutes? 1 Answer
Reversing rotation back to zero 0 Answers