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.
2010-03-31 07:43:09
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
2010-03-31 07:58:55
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.
2010-03-31 08:10:45
The only matrix i am applying is from CreateLookAt, and it seems it is applying some sort of translation as well as rotation..
Neosani
2010-03-31 08:14:18