Unity Development — Hitbox

If you are at all into fighting games, I am sure you have heard people talking about hitboxes before. Maybe even a little too much. Now you are finally going to understand everything they are talking about. Well… maybe not everything.

Say we have a Player object and they have an attack animation. We are going to have a hitbox be a child of that object and they will be adjusted in the attack animation itself, simulating the swinging of a sword, a full kick, a punch, or any other attack with movement.

In my project, the Player’s animations are controlled by a child called ‘Sprite.’ That is just fine. As long as the hitbox is a child of whatever object is holding the Animator.

Your Hitbox should have a Collider and a Rigidbody to detect collision. Make the Collider a trigger.

In the Inspector, you should also set the hitboxoff at the top.

In the Animation window, go to your Attack animation. For every animation you can hit the Record button (red button next to ‘Preview’) and make changes to attributes in the Inspector. Because the hitbox is a child of our object with the Animator, it applies there as well.

Go to the first frame, hit Record, and set the Hitbox to be enabled on the Inspector. You will see that it sets a new key in the animation window and has recorded. Still in the first frame, move the hitbox’s transform and edit the Collider to properly encompass what you wish to be the area of attack. In our case, it is around the Player’s sword.

It is going to be tedious, depending on how many frames you have, but you must do this for each frame of the animation. And be sure that you are in Record mode the whole time. Make it as precise as you wish, or leave some wiggle room.

Do lots of play testing after setting up your hitboxes. You never know if someone is going to come around and say they are unfair because one reason or the next. Luckily we live in a world with online updates, so even professionals need to readjust sometimes.




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

New Look, New You: Making a Successful Esports Rebrand

The Top 5 Most Interesting Takeaways From Fishing Town

MetaMetaverse Weekly Digest Mar 7–13th

Weekly digest contents

Beyond winning, or: Are ya participating in the cultural event of Blaseball, son?

Fanmade Yellowstone Magic team logo

(ありがとう) Thank you, P Studio - Atlus

Shin Megami Tensei Persona 3 Portable Wallpaper

Lonely Mountains: Downhill — Snap Judgement #4

Assassin’s Creed Odyssey and the Power of Nostalgia

My Top Ten Games of the Year 2021

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Christopher Graf

Christopher Graf

More from Medium

Transposer Virtual Camera Explained in Unity’s Cinemachine

Adding a thruster speed boost on keypress

Collision vs Triggers: in Unity

You Died — Creating a Retro Game Over Behavior