# 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.

## 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 on other sites
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 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 on other sites
bennyW: I really like that, actually :) Why didnt I do it that way? :P

##### Share on other sites
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 on other sites
Should be able to have as many keyframes as you like, as long as your time range is 0..1, right?

1. 1
2. 2
Rutin
22
3. 3
JoeJ
18
4. 4
5. 5

• 15
• 40
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631725
• Total Posts
3001905
×