Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Meaning: how do I build my animations/system so that I can have swords blocking each other? I honestly believe this is the hardest part of a game: I need animations to interact with each other. If a monster uses attack 1 on hero 2, then both NPCs have to play a different animation based on,

A, How big these NPCs are. I need them to be able to be scaled (monsters can grow, but when it jumps on a small player, it still has to look just as fitting as with other sizes) B, Speed of the monster when it runs up for the attack. C, Countless other things I suppose.

How do I achieve this? KI, Pathfinding... all that is meaningless unless I can build a believable combat system.

share|improve this question
    
Are your animations pre made or created using code? If they're pre made you will find it difficult to get your result. On the other hand, most games (Street Fighter and Age of Empires to name two) don't do this, and they are very popular. It depends on your game of course, but you may find that you don't need to do this to make the game great. –  annonymously Jan 23 '12 at 10:48
1  
They are motion captured or done manually in Maya. Hm, doing them in code.. so you mean calculate the path of the sword swinging arm completely in code so that it hits the right spot? I haven't thought about that, I think making that movement look realistic in all situations would be near impossible? –  Blub Jan 23 '12 at 11:03
1  
Which is why most games don't do bother trying. You can make it look pretty good just using a generic swing animation. Doing it in code is also very expensive –  annonymously Jan 23 '12 at 11:10

1 Answer 1

The most common method is to not bother. Just use generic animations like most MMOs. One guy makes an attack, the other guy makes a blocking animation. Damage is dealt, numbers appear, everyone is happy.

Now, if you actually give a damn about how your game looks, you need to expend effort.

The idea is fairly simple. To coordinate animations between entities, you need to... coordinate animations between entities. The two entities need to talk to each other and work out which animations each of them will play.

One entity should probably be the "leader" in terms of who's in charge. It dictates when things will happen and how they will occur. Let's say the attacking entity is always the lead.

The attacker informs the defender that he's being attacked. So now the attacker references the defender and vice-versa.

Next, both must select which animation to play. This is generally done by a table or something similar based on the available parameters. For each possible set of parameters that affects which animation to play, you have an entry in the table that says which to play. So you'd have ranges of enemy sizes, self-sizes, ranges of distances to the target, etc.

The attacker and defender play a different animation obviously. But the tables they select from are designed to match: given the same attacker size, defender size, and distance, the attacking animation selected will match the defender's animation selection.

Then they play their animations. Note that timing may need to be involved here. Especially if distance is involved, you generally don't want the defender to be defending until the attacker is close enough. So he won't play his animation until the attacker reaches a certain distance. This requires the defending entity to track the position of the attacker and play the animation at the right time.

Your biggest problem (and the reason why most games punt on it and use generic anims) is likely going to be what happens when a third entity gets involved. If you're already in the middle of a lengthy scripted sequence, what do you do if someone else tries to attack you?

This is generally not a good thing. So oftentimes, you simply say that nobody can attack someone who is attacking/defending currently. In some games, elaborate animations are only used for specialized events. Generic animations are for basic fighting, but you might have a special anim for the final blow.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.