#### Archived

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

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

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

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

Cheers

Matt

##### 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 on other sites
Thanks guys, i''ll give it a try, thanks for help again.

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633679
• Total Posts
3013294
×