Jump to content
  • Advertisement

Archived

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

monkey_face

weapon question

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

in my first person world, i''m using the following formula to move the camera forward: xPos -= sinf(D3DXToRadian(yRotation)) * .2f; zPos += cosf(D3DXToRadian(yRotation)) * .2f; This works fine, but now i want to include weapons, and i''m going to use the same two statements to move "rockets" forward. but what do i increment/decrement the y Pos with? do i have to check whether the user is "pointing" up or down? or is there a formula that takes care of this? it seems like i would need to take either the cos or sin of the X rotation. thanks! ps -> i used this formula to test, and it kind of works, just wondering if it''s totally off: theObject.xPosWorld -= sinf(D3DXToRadian(theObject.yRot)) * .2f; theObject.yPosWorld += sinf(D3DXToRadian(theObject.xRot)) * .2f; theObject.zPosWorld += cosf(D3DXToRadian(theObject.yRot)) * .2f;

Share this post


Link to post
Share on other sites
Advertisement
You will be better off in the long run if you start to use matrix operations instead of your current method. As you rmotion becomes more complicated, the matrix method will make more and more sense.

Take a look at the matrix tutorial in the SDK to get started.

Share this post


Link to post
Share on other sites
maybe i wasn''t clear: i do use matrix operations, but the formula i''ve put in my initial post is in the "arrow up" event, so the user can move forward no matter what direction they are looking. i am using matrix operations to transform objects. sorry about that.

Share this post


Link to post
Share on other sites
maybe i wasn''t clear: i do use matrix operations, but the formula i''ve put in my initial post is in the "arrow up" event, so the user can move forward no matter what direction they are looking. i am using matrix operations to transform objects. sorry about that.

Share this post


Link to post
Share on other sites
OK - but I would still say that you might want to use a more matrix based approach.

rotate the user to the walking orientation
translate the user forward along the new forward vector
rotate the user in the view direction

Therefore, to answer your real question: rotate the projectile to the viewer orientation and translate along the new forward vector. This will work for any viewer orientation (up, down right, left, etc)

Edited by - CrazedGenius on January 13, 2002 12:35:33 AM

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!