Hi guys,
I’m just getting into programming, so I don’t know much, but I was wondering if anyone had an idea of how the Batman games’ combat system works. Like, if I were to try and duplicate it in my game, what would be the overall process.
I just figured that with the bright minds on this forum, they might have an idea of how they would do it, or have read a good article they can pass along. The other good question is, can we do it in Unity? Thanks guys!!!
Disclaimer
No, I’m not making a Batman clone. I’m just trying to learn more about programming by figuring out how to do complex things.
The combat is very, very smooth. You just click to attack. Then the attack animation is played, but it’s always different and dependent on what is going on. Batman can grab enemy’s heads and throw them.
I’m just trying to figure out things like:
How would you get the character to always hit a certain place on the enemy, no matter which direction the player is facing.
Ok, I haven’t played the game and I don’t know for sure how they do it but here’s my best guess.
I would reckon that it works a bit like the Unity locomotion system. So its not that there’s a set list of animations that it has to choose from.
Instead the Batman character is rigged as series of rigid bodies which can move and bend in certain places.
When you click to attack it knows where all these bodies are and where they need to end up. It then applies various rules to get them where they need to go which creates the animation on the fly. I think this is called Inverse Kinematics
With a bit of luck someone more knowledgeable can confirm or deny this and maybe give more information on how its done.
you have a lot to learn start small with animation (how to blend and layers using IK) then go from there, you will see that it’s really hard to do as they did, and when you said in the Disclaimer your not trying to copy them, by all means do so
but good job choosing one of the best combat system i have seen.
With this info I would say that it probably is all animation presets and the selection from presets is either random or depends on something. So probably a really simple system (from programmers point of view), but with a lot of work that has gone to animating.
No project in unity that i know, but the good news is unity got mecanim for the animations and without that it’s impossible to great such complex and accurate characters (you have to get pro to be able to use IK in mecanim)
I played both games and that’s my guess. Presets animations for both player and enemies. Code that factors distance/rotation/state to play the right animation with some randomization. IK to fine tune roots and maybe hands/foots/head(hard to tell).
Code wise it shouldn’t too hard to do, harder if you add environment interaction and 1on2 moves like batman. Hardest part would be the amount of animations and keeping them in-sync. Not something you want to tackle without a great animator.
If you look at this batman video you probably have enemy animations ready to sync up with batmans animations. No more then 2 bad guys will try to fight batman at the same time.
->Batman fighting 1 enemy
->Batman knocking out enemy on the ground
->Batman fighting 2 enemies
->Batman knocking out 2 enemies
->Batman changing targets with enemy in his way (flip over)
->Batman changing targets with no enemy in his way
I would try watching a bunch of batman fight videos and see if you could work it out logically, then try coding it. I would love to see if unity had somekind combat tutorial like the spy tut, it would be a good to show off mecanim.
It’s actually not that complicated - it’s a series of synced attack animations between Batman and a grunt. A whole bunch of them - covering many different directions, distances, and facing angles. All that’s happening on the code end is the logic is determining who the next target is, intelligently picking the animation that is the closest match, and then lining the attacker and target up in order to play the sync’d animations. That’s why you see Batman slide around all over the place during the fight, they disguise the translation/rotation fix-ups as a jump or slide.
As for keeping only a few enemies attacking the player at one time, it’s done using a ‘ticketing’ system. Only enemies with a ticket can attack, while any enemy without a ticket stands outside the fight and waits for a ticket. Once an enemy is dead/incapacitated/out of range they lose their ticket, and it’s given to another enemy. So if you have 15 enemies on the screen, but only 4 tickets, the player is only getting attacked by 4 of them at any given time.
I’d add these ticket behaviours: tickets have a timeout, and then they time out they generally get pushed to the back. This also happens when bats moves around a lot. The distances are checked and a new priority is sorted out. Low priority enemies far away have an occasional check for something they can throw at batman. This seems like very straightforward stuff and certainly isn’t the innovative part of the fighting in batman. This is KISS programming that’s very effective and works well to solve this problem.
It’s the sort of stuff that would be fairly simple to get going in Unity and do it well. You’d be limited by all the situational animations you’d need to make but that game isn’t doing magic either.
It’s not that hard. I guess It uses Unreal Engine 3. Mecanim can be used to implement such a thing and needs some scripting in the flow of animation may be using IK and some blending between layers.
i know it’s been two years since the last update on this post, but i just wanted to say that you don’t realy need IK for this, just synchronized animations, if you notice on the videos, at some points batman hovers at some places and it’s usaly at some kind of a freeze frame, this is easily noticed at the slow motion video somebody posted. I wonder if you still are working on this? i kinda do the same thing in my game with pretty good results, just trying to polish it even more