Moving a character forward/backward in 3D world.....

Started by
2 comments, last by nlo 22 years, 9 months ago
here''s my question, i just write a character class that load .X file, i can rotate it in 3D world, but how can i moving a character forward/backward base on the rotations ?? B''cuz now it only translate along with the world X/Y/Z, any tutorial talk about that ??
Advertisement
If your character is rotated so that he always faces down the positive Z axis, you can take the Z axis vector directly from the model''s transformation matrix and move him along that to make him walk forwards:

ModelMatrix._41 += ModelMatrix._31 * Magnitude
ModelMatrix._43 += ModelMatrix._33 * Magnitude

That should move him in the X and Z plane

Cheers

Matt



You want to use the character''s forward vector with it''s rotation matrix.

Just apply the matrix to the character''s forward vector. This rotates it so it points forward after the character has been rotated, and so is the vector you want to move along. The character''s forward vector is simply the forward direction in the model. E.g. if the character was modelled facing into the screen, with z forward, then do:

vMove = ApplyRotMatrix(mRot, vZ);

where vZ = {0, 0, 1}, the vector along the z axis. This works for simple rotations around the y/up axis and for more complex 3D rotations.
John BlackburneProgrammer, The Pitbull Syndicate
Thanks guys, i''ll give it a try, thanks for help again.

This topic is closed to new replies.

Advertisement