Jump to content
  • Advertisement
Sign in to follow this  
gabzuka

First person character's arm

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

Hi! I've searched everywhere for this but I don't know how to search for it, so obviously I found nothing. I'm making a game in first person view, I've got my camera working good, with the arrow keys I go forwards/backwards and strafe left/right, with the mouse I look around, the problem is that I want to put the main characters arm in front of the camera like in a normal FPS. Every time I move I move the arm object to the actual camera position and it works great, the problem is when I move the mouse I need to rotate the arm so it stays in the center of the screen ... How can I do that? is there somewhere I can find information about it? Hope you can help me! Thanks a lot!! G

Share this post


Link to post
Share on other sites
Advertisement
How are you rotating your camera? Apply the same transformation matrix to the arm as you do the camera (instead of just the translation component as you are doing now).

Share this post


Link to post
Share on other sites
If you're transforming the world by using glTranslatef and glRotatef instead of gluLookAt then all you simply need to do is apply the Y-axis rotation after you've drawn the arm model, then draw the rest of the scene.

Obv, replace Y-axis with whatever your up-axis is.

Share this post


Link to post
Share on other sites
Alot of oldschool FPS games, where there was just the 'arm & gun' (no actual body when you look down) would render the gun after the rest of the scene using its own Projection & Modelview matrix, that was it didnt matter where the camera would be pointed. It also meant that the gun-sway/bobbing could be done just by playing with the guns personal modelview matrix...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!