Original Post
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;