Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


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

This topic is 6269 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 ??

Share this post

Link to post
Share on other sites
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



Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!