Jump to content
  • Advertisement
Sign in to follow this  
gcard28

animated character aiming

This topic is 4266 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 having a problem that I can't seem to find a solution to. Say I have an enemy AI soldier. He walks up to the player who is above him and takes aim at the character by raising his arms to the player's position. If the player jumps down from his ledge that AI player lowers his arms the appropriate amount so that he can aim at the player at his new posision. My question is I can find the angle and vector the enemy AI should shoot at but I have no idea how to translate this into something that will make the enemy AI move his arms and torso to match where he needs too shoot. Do I need to manualy move bones in the hierarchy in my model? Or is there a better easier way to do this? Thanks for anyones help!

Share this post


Link to post
Share on other sites
Advertisement
It's been a while since I've done any character animation work (recent projects involved spacecraft, which dont need much skinning ;), but here's how i used to do it:

[There's most likely a better method now that people use]

- For the vertical range over which a character can aim, create a bunch of discrete poses (i used single-frame animations for this, but you can have some ambient animation in there too, for slightly wavering aim, etc.)

- Each pose aims at a particular 'ideal' angle relative to the xz plane.
- Work out the angle between the xz plane and your target

- Choose the two poses closest to that angle (there is one above, and one below)
- Linearly interpolate between them, based on the desired angle.

This is simple, fast, and works pretty well. If you have 5-6 poses, the linear interpolation isnt particularly noticeable either.

Let me know how it turns out for you :)

Regards,
Chris

Share this post


Link to post
Share on other sites
Another way is to have two aiming anims. One that starts from the left at frame 0, and ends to the right at 1. Then another the starts from up at frame 0 and points down at frame 1.

What you can do then, is figure out where the player is within the enemy's min-max ranges for left and right, getting a value from 0 to 1. Plug that into your animation system for the left-right anim, do the same for the up and down anim. Your animation system takes care of the aiming for you, all you had to do is come up with some values to plug into it.

BennyW

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I like the 2 frame animation method from BennyW. However is it possible to have smooth interpolation with only 2 keyframes.... the character will be moving and his target aim will change as a result. I just wonder if 2 frames are enough to generate the correct frame animations.

Share this post


Link to post
Share on other sites
Should be able to have as many keyframes as you like, as long as your time range is 0..1, right?

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!