Jump to content
  • Advertisement
Sign in to follow this  
jochenstier

Attaching Camera/Weapons to a character

This topic is 3470 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 am trying to figure out the best way to attach a weapon and a camera to an md5 skeletal character animation. I am already running the animation and have a camera attached to the head bone. The walking animation is connected to the “w” key and as the character is moving around you get nice first person experience. The problem I am now trying tackle is how to control a weapon. My first inclination was to attach the weapon to a hand bone and then create an animation pose for aiming which raises the hand holding the weapon into the proper alignment with the head, and subsequently the camera. I imagine this could work, but how do I deal with the user using the mouse to move the aim. Right now, it is setup that up so that the up and down movements actually change the camera elevation without effecting the characters’ skeleton; left and right just turns the entire character. In this case scenario the weapon does not stay aligned with lateral movement of the camera, because the skeleton has not changed. What’s the solution here? Should I control both the arm and the head using the keyboard input? What happens to the conflict this creates with the original animation sequence? I couldn’t find a solution on first glance, but I imagine it’s a common problem.

Share this post


Link to post
Share on other sites
Advertisement
Hi,

I think that this is a common problem. The easiest solution is indeed to just change the camera orientation. A more complex approach is to use inverse kinematic(IK), in this case you control single bones (hand or head) and recalculates the other bones orientations (head->neck->spine...). The recalcuation needs constraints to look prober. All animation tools provides IK and I believe many games too. Hmm... there should be an article about IK in games in one of the GPG (game programming gems) books, don't remember which book. In this case google should be your best friend ;-)

--
Ashaman

Share this post


Link to post
Share on other sites
If I just change the camera orientation, then the weapon will not stay in front of me. Just imagine you are holding a gun and then turn your head. You will not be pointing at anything anymore. It seems like the solution would either have to involve IK, or simply just faking it by always painting the aim onto to screen. The character could still be in an "aiming" pose, but whatever the gone is pointing at may be different from what the character is looking at. That's probably easy enough...

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.

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!