Hitboxes! The power is all in hitboxes.

Hitboxes, they are what let you fine tune an attack. Although I have worked with colliders previously, this is a bit more fine tuned.

As someone that has played a lot of fighting games, here are two examples of some extremely strong hitboxes in red. The hitboxes a character has can make or break them so it is important to be careful with them! Though, this is a single player game.

The hitbox itself is just an empty object as usual. With the collider set to only turn off during the attack, we can now continue.

Now the issue comes in fine tuning the hitbox. For this we end up using timeline. Thankfully I have quite the experience from the previous project so it was quite simple, just a bit tedious however.

With each of the key frames set to match the swords movement, the end result is as we see it here. Success… but there ends up being a problem. My player has a collider hitbox, and when the swords hitbox collides with it, my player also gets hit. There are ways to fix this, and the route I ended up taking was to use the layer system in unity.

Using the layer pulldown next to tags, I put both the Player and the Sword hitbox into its own layers.

Now with the sword layer set to not interact with the player it works perfectly! No more hitting yourself.

Oh right, I also need to give the enemies hitboxes as well!

See you next post!