- Home /
 
transform.Rotate and Rigidbody.MovePosition
Hello there, I'm trying to do a hover vehicle racing game (a WipeOut clone)
Initially I'm trying to make the ship rotate around itself depending of the Horizontal axis, and that works well, but when I try to add a constrained rotation emulating the oscilation of the ship when turning, both rotations seem to "clash" and they don't work together as they should.
My code right now is like this:
 void Turning () {
     float oscilation = -15f;
     if (inputHorizontal != 0) {
         transform.Rotate(0, inputHorizontal * turnSpeed, 0);
         Quaternion rot = Quaternion.Euler(0, 0, inputHorizontal * oscilation);
         rb.MoveRotation(rot);
     }
 }
 void FixedUpdate() {
     Turning();
 }
 
               Any help?
Answer by theterrificjd · Dec 24, 2017 at 09:09 AM
Take a quick look at https://docs.unity3d.com/ScriptReference/Transform.Rotate.html I think you may have your set up a bit incorrect.
I think it would be more like
 transform.Rotate(Vector3.right * (inputHorizontal * turnSpeed),Space.Self);
 
               Also, make sure your rigidbody is kinematic for smooth MoveRotation function. Otherwise, it might be better to figure out a solution applying some combination of torque/angular drag/addforceatposition.
Your answer
 
             Follow this Question
Related Questions
Orbit cam and Rigidbodies aiming 0 Answers
Rigidbody wont rotate in the other direction. 0 Answers
Rotate Rigidbody on Two Separate Axes Independently to a specific angles 0 Answers
Why can't I assign a rotation to a rigidbody Object? 1 Answer
How not to make a RigidBody not go into ground when tilted foward? 1 Answer