views:

181

answers:

1

I am trying to rotate an object to face the direction it is moving in. We want it to face the normalized velocity vector.. help... pls...

+1  A: 

Have you tried Matrix.CreateLookAt (MSDN)?

// Matrix.CreateLookAt(eyeLocation, lookAt, upVector); 
Matrix.CreateLookAt(currentPosition, currentPosition + velocity, Vector.Up);
Marcel J.
Just to clarify, our object is on the x,y plane and we want to rotate about z. I tried your suggestion but it is swinging around the x-axis as if it is applying translation before rotation.
Neosani
If you have a 2D plane you might prefer `Vector3.Backward`. And if it seems that it's applying translation before rotation, why not just switch the ordering of the matrices? The ordering should be `RotateMatrix*TranslateMatrix*Vector`. `A*B != B*A` if you use matrices.
Marcel J.
The only matrix i am applying is from CreateLookAt, and it seems it is applying some sort of translation as well as rotation..
Neosani