- Home /
Hit detection for Fighting Games?
Hello all. I am a bit confused on how I should be approaching this. I'm interested in starting a 2.5D Fighting game, similar to modern Capcom fighters like Street Fighter IV. I am wondering how I would go about creating a type of hitbox detection used in these games. Here are some images for reference.
Fighters of this nature generally have very specific, hand-done hit boxes used for collision. My first thought was to add Box Colliders to different parts of my armatures, but I felt it was a bit inaccurate. Hitboxes tend to usually be bigger than the body part they are mimicking, or in the case of the second screenshot, don't follow the body at all.
Anyone have any suggestion they can throw my way?
Hey,
I'm not sure i get what you are asking right, so let me ask a few questions: What is the difference between the red and green box? Did you try mesh collider?
In the example above, the green box would be the "hurtbox", hitting any part of that box would deal damage to the character. The red one is sometimes called a "strikebox", this is the area or range your attack represents. These hitboxes are dependent on the character animation and constantly change in size and quantity.
Basically, If YOUR strikebox (red) collides with a opponent's hurtbox (green), you will deal damage to them. I'd like to recreate a system like this. A bit unnecessary ter$$anonymous$$ology, I'm sorry. Just trying to be a bit more clear.
These boxes are represented in 2D, not 3D. I am not exactly sure how a mesh collider would assist me in this case. $$anonymous$$aybe you could elaborate?
Ok, i understand a bit better now. The ter$$anonymous$$ology is necessary though, since in my opinion the hurtbox is not the same thing as the strikebox.
Basically what you want here is that a character's strikebox only collides with another player's hurtbox. For this you might need to look at the layer based collision detection (http://docs.unity3d.com/Documentation/Components/LayerBasedCollision.html ).
I mentionned the mesh colliders because you said that box colliders were inaccurate, and it is a way to improve your accuracy. It might be a way to have your colliders match your model (for example for the foot).
As for the colliders in 2D or 3D, it's basically the same, but since your character models are in 3D, i would recommend to have the colliders in 3d as well, because it might be more accurate.
So tu sum up: 2 different colliders (hurtbox and strikebox) The strikebox can collide only with hurtbox Define the colliders as you want depending on the accuracy you need.
Thanks a lot for the response. =)
Box colliders being "inaccurate" was the wrong term for me to use. Hitboxes tend to be very exaggerated in most fighting games.
Quick example: A opponent that is crouching would logically have a smaller hitbox. In a realistic fighting game, any attacks that would normally aim for the head, such as a roundhouse kick, would completely miss. However, in a 2D fighter such as Street Fighter, this attack would still connect because the strikebox is much larger and exaggerated than the limb it is actually representing. Which is why using a mesh collider confused me a bit.
$$anonymous$$y question now would be how would I go about creating these boxes, based on the animation of the character.
You need to attach the collider to a specific joint in the skeleton hierarchy of your character. For example, attach a strikebox to the foot of the character. This way, it will move with the feet.
That's for basic hitting purposes (kicking, punching, etc.). If you want to do something like for blanka, you need to control the switching between strike colliders in your control scripts (for instance disabling normal strikebox to enable a larger one when you do the electricity thingy).
It all depends on what exactly do you want to do.
Answer by Max_Bol · Jun 05, 2015 at 11:08 PM
Even if this is 2 year old, I would like to give some tips considering that I found it at the top of Google listing.
Like some others have mentioned, a way of doing this is by using mesh or box collides linked to each body's parts.
Personal, there's what I would suggest :
1) For the hurt box (which we tend to call "Hit box"), uses box colliders on every major bones from the rig. Don't do each fingers or toes for the sake of the players' CPU.
2) I would advise also to put each player to a different layer so, that way, you can make sure that each player can't harm himself. Unless you're planning a 16 vs 16 fighting game (which would be quite chaotic) you can keep each player on a different layer (and literally name those "Player1", "Player2", etc.)
3) For the strike box (Which we tend to call "Attack area"), you could uses a box collider or capsule collider if you wish for a bit more "smooth" cornered strike box. If you did the step 2 of putting every players on a different layer, you can easily make it so that each Strike box can ignore (or not) the player's own layer. It's especially useful if you got some magical attacks that uses some particles.
I'm currently working on an early version of a game that seems similar to Super Smash Bros and that's how I'm doing it.