Jump to content
  • Advertisement


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


algo for moving in the direction of object facing

This topic is 5645 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

ok! i managed to get the object rotates abt itself... now i am figuring out how to make it move in the direction it is facing... any ideas to share? thx! edwin

Share this post

Link to post
Share on other sites

The following members in your world matrix form a vector that points in the direction the object is facing:

_13, _23, _33

Assuming there are no scales or skews in your matrix (if it''s just rotation and translation, there won''t be), then that vector is also normalised (it''s length == 1).

So all you have to do is multiply that vector by the distance to move and add it to the translation part of the world matrix:

vec3 direction;
direction.x = worldmatrix._13;
direction.y = worldmatrix._23;
direction.z = worldmatrix._33;

worldmatrix._41 += direction.x * DISTANCE_TO_MOVE;
worldmatrix._42 += direction.y * DISTANCE_TO_MOVE;
worldmatrix._43 += direction.z * DISTANCE_TO_MOVE;

Simon O''Connor
Creative Asylum Ltd

Share this post

Link to post
Share on other sites
sighz doesnt seem to work...
looks like its due to the design of the scenegraph...
(i am using the one provided by GI (week 5 meshviewer))



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!