animated character aiming

Started by
4 comments, last by Qatal 17 years, 5 months ago
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!
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
die or be died...i think
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
bennyW: I really like that, actually :) Why didnt I do it that way? :P
die or be died...i think
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.

Should be able to have as many keyframes as you like, as long as your time range is 0..1, right?
die or be died...i think

This topic is closed to new replies.

Advertisement