# Problem with 2D rotation, rigidbody and momentum.

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. At first I set up a simple physics script attached to my rigidbody that went 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 worked quite as expected. The only problem is that I had 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, or none at all.

Then I did some experiments, and I tried to change the force direction according with the rotation, in order to reduce momentum. I did it this way:

``````#pragma strict
var craftSpeed:Vector3 = Vector3 (5,0,0);
var eulerAngleVelocity:Vector3=Vector3 (0,0,10);
function Start () {
rigidbody.velocity =  craftSpeed;
}

function FixedUpdate () {
var velocity: Vector3 = rigidbody.velocity;
rigidbody.velocity = Vector3.zero;
rigidbody.velocity = transform.right * velocity.magnitude;
var deltaRotation : Quaternion = Quaternion.Euler(eulerAngleVelocity * Time.deltaTime* Input.GetAxis("Horizontal"));
rigidbody.MoveRotation(rigidbody.rotation * deltaRotation);
}
``````

Which seemed to work pretty well at first (nevermind the speed values: I already tweaked them in-engine). The problem is, after a few rotations, if I suddenly stop rotating, my object slows down and stops. It doesn’t move until I rotate again. How can I avoid this behavior?

Sorry, I’m really dumb, I left Gravity on on the rigidbody. Cannot delete the thread, though.