Game Development Community

dev|Pro Game Development Curriculum

Tactical AI Kit: Adding Life with Animations

by Bryce · 01/07/2009 (8:26 pm) · 12 comments

Hello Everyone!

A new record for me--two blog posts in one week. Either I'm very productive or I have no life, I'll leave you up to decide that.

This blog post isn't as long as most other posts I usually make, because this isn't such a complex feature, but it's something that I think anyone interested in buying the Tactical AI Kit when it is released would like to see.

Having done the internal workings of the TAI Players to death (but not completely!), I decided to move onto the external features, in other words, how the NPCs look. In my opinion, a big part of having realistic, convincing artificial intelligence is proper animations. Anybody who played the demo I released in October probably noticed the way the characters animate. Not only do the animations suck, but they play in a non-natural manner. When a TAI Player decides to take vertical cover (along the edge of a wall, the storage containers, etc) that requires them to change their XY position to return fire, they simply used setMoveDestination() to go there. I didn't have a strafing animation, so the NPCs would just slide out of cover, but even if I did have a strafing animation, it would still look quite unnatural to run out to return fire like that.

By modifying the Multiple Positions Resource by Erik Madison, I created a function called setCoverPosition(val), which sets the NPC's animation depending on how he is using cover. The setCoverPosition function takes one argument, which is a number from 0 to 5. The number decides which animation the NPC should play:

0--StandHide (Hide behind cover we can't shoot over)
1--StandRight (Fire right around a corner)
2--StandLeft (Fire left around a corner)
3--CrouchHide (Hide behind cover we can shoot over)
4--CrouchFire (Fire over cover)
5--Reset (Brings us back into the regular, no-cover move state)

In the NPC's find/use cover state, a check is made to see how exactly the NPC is using cover, and sets its cover position accordingly. It's a very good effect, and looks much more natural and convincing. Some screenshots:

img211.imageshack.us/img211/1664/19879569to4.jpgimg211.imageshack.us/img211/3649/57774571hg7.jpgimg291.imageshack.us/img291/9814/36070622xm4.jpgimg211.imageshack.us/img211/8646/96078031bd3.jpg

#1
01/07/2009 (9:27 pm)
this look great, keep the work up
#2
01/07/2009 (11:27 pm)
Nice man as always great work!
#3
01/08/2009 (1:34 am)
I want another demo!
#4
01/08/2009 (2:34 am)
This is looking great. Cant wait for another demo myself. :-)
#5
01/08/2009 (2:55 am)
bryce, following the progress of your kit has been a pleasure. Even though I at times have been worried that 'feature creep' would kill or derail the project, I have to say; Your doing an extremely well balanced job.

Not only have you added in a ton of features since I saw TAI mentioned first time, you have also done it keeping 'the red thread' in mind and worked steadily on improving a very thought through product.

you bro ;) have my sincere respect, and my credit card waiting :P

-keep up the spirit!
#6
01/08/2009 (3:18 am)
Either I'm very productive or I have no life.

I usual shout "Both!".

Your work has started to move away from looking good to looking damn impressive.
#7
01/08/2009 (5:51 am)
@Duncan and Mike: There will be a second demo that gets released right before the release (whenever that will be, I hate deadlines). I'm hoping to have several missions, each set up to specifically demonstrate a certain feature.
@Kory, Scott, Christian, and Steve: Thank you! This kind of support is what keeps me at this :-)
#8
01/08/2009 (7:52 am)
As long as you don't go ahead and add a third-person cover system, it's all good ;D

Something else that ironically adds life, I think, is damage animations. Halo is the game that sticks in my memory most for this - when you hit an Elite, he would actually look like he had just been hit by a superstrong supersoldier from the superfuture - and it hurt! I find it the most realism breaking thing when enemies just play a generic little 'ouch' wobble and possibly a grunt of discomfort after I've shot them in the face.
#9
01/08/2009 (2:34 pm)
Good job!

One thing that came to mind is that you should probably move your setCoverPosition() reset value to 0 rather than 5. This allows you to easily extend the command to allow additional positions in the future, without having them go past the reset value. i.e. 6+ This change should also handle setCoverPosition(false), which can be a handy concept to have.

- Dave
#10
01/08/2009 (2:46 pm)
@David: Yeah, that was my original plan, but I designed it poorly. I'll rework it eventually, but it won't be hard at all. I just need to change around the switch function in Player::pickActionAnimation() a little.
#11
01/11/2009 (1:52 pm)
How would the player take cover?

Would it be like RS6: Vegas? Where you would hold down mouse2 to take cover?
Or would the player not be able to take cover and shoot from it?
#12
01/11/2009 (6:45 pm)
This isn't a full working cover system for living players, though it could certainly be a good start. This system is only useful right now for AI Players; it helps them decide which animation to play to lean out of cover, take cover, etc.