# Rotating a character's velocity?

I'm coming along quite well in this project of mine, but I can't seem to get the turning quite sharp enough. As it is, when the player directs movement in a new direction, the velocity gradually changes to that direction. It makes for some slightly slide-y controls. So I want to turn the direction of the velocity instead. The closest thing I've come up with so far is this:

``````rigidbody.velocity = Vector3.RotateTowards(rigidbody.velocity.normalized, desiredVelocity.normalized, Handling*Time.deltaTime, 1000)*rigidbody.velocity.magnitude;

``````

And it works great on a flat plane, but my character is going to be walking on walls and riding bumpy surfaces as well. This particular function makes the character stop doing that, and almost makes it stop adhering to gravity.

If anybody has skill with Vector3's or Quaternions, this noob would be quite grateful for help! ^^;

What we do is grab the magnitude of the momentum/velocity then multiply it by a normalized vector representing forwards in the new chosen direction. this makes the objects turn without drag, skid or slow-down.

As a note hard setting the velocity of rigid bodies might make the physics look a little odd, but we also frequently like to rely less on applying forces (which can look a bit rubbery and unresponsive), and direct manipulation of velocity etc is "usually" fine.

Cheers,

James

Changing a rigidbodies velocity is most often not the best solution. I don't know what kind of game you are creating, so maybe this answer is completly useless.

Instead of changing the velocity directly you should apply forces to it. By balancing the strength of the forces and the drag of the rigidbody you should be able to get the wanted control feeling.

Just add a constant force too it instead, and limit the drag, and it'll do just what you want :).