I am in the midst of creating an FPS game using XNA. I am using the camera class from the First Person camera demo from dhpoware.com, and everything is working great. What I'd like to implement is the ability to press the right mouse click and then the view changes so that you look down the gun, like the following image:


I have searched and searched but haven't found anything that will help me out, or at least point me in the right direction. Can anyone help?

  • \$\begingroup\$ This gun looks like a 2d overlay to me. Are you expecting it to zoom? \$\endgroup\$ – Skizz Oct 11 '11 at 14:26
  • \$\begingroup\$ The gun is a 3D model. Its a screenshot from Call of Duty. \$\endgroup\$ – Neil Knight Oct 11 '11 at 14:26

Isn't it as simple as rendering your gun geometry (or 2d HUD style gun) near the camera and narrow the field of view.

  • \$\begingroup\$ Care to share some code on narrowing the field of view? \$\endgroup\$ – Neil Knight Oct 11 '11 at 14:14
  • 2
    \$\begingroup\$ @Ardman you set the field of view when you create your projection matrix - recheck that bit of your code. \$\endgroup\$ – Jonathan Dickinson Oct 11 '11 at 14:20
  • \$\begingroup\$ I managed to do this using a 3D model. My code needed altering in order to adjust the offset of the gun model and also allow the code to alter the Field of View outside of the Camera class. \$\endgroup\$ – Neil Knight Oct 25 '11 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.