- Home /
Physics based rigidbody rotation with a constant force
Hi there, I'm trying to move an object to the right of the screen with a constant velocity. Then I want to let the player rotate this object clockwise/couterclockwise on the z axis, and have the object move accordingly. I set up a simple physics script attached to my rigidbody that goes like this: var rotateSpeed = 360.0; var thrustSpeed = 25.0;
function FixedUpdate() {
transform.Rotate (Vector3.forward * (Input.GetAxis("Horizontal") * rotateSpeed * Time.deltaTime) );
rigidbody.AddRelativeForce (Vector3.right * thrustSpeed * Time.deltaTime);
}
Now, it works quite as expected. The only problem is that I have got way too much inertia: if I rotate, the time my object needs to actually change direction is really really long. I'm aiming to a slicker control (so you rotate and immediately change direction, with just a little hint of inertia. I'm a bit of a newbie with physics, so I really don't know where to go from this point on. I tried increasing drag, but this obviously decreases the speed of my object.
Any advice?
Have you tried increasing both, the drag and the thrustSpeed?
Answer by swordofnoah · Jul 10, 2013 at 08:29 PM
You could always increase the velocity after increasing drag. If that isn't working for you or you don't like it than you could directly change the rigidbody velocity, however this would eliminate all inertia.
Your answer
![](https://koobas.hobune.stream/wayback/20220613071210im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Rotating my character only while moving in a 2D plane 3 Answers
Returning a rigidbody back to its original x and z rotations through physics forces. 2 Answers
How best to control rigidbody rotation within constraints 0 Answers
can anyone help me stop a rigidbody from rotating around its z axis 1 Answer