Question on hitboxes and an online fighting game

This is more of a general design based question.

I am working on a 2D fighting game and was looking for some advice on hit boxes. Since I will have an online multiplayer component, I was curious which design practice sounds the best for networking code:

  1. For each character, have all their hit-boxes attached with the character prefab and simply activate them. So all the hit boxes are in the scene, placed in relation to the character and they only activate when the correct attack is called.

  2. Instantiate each individual hitbox in relation to the character and delete the hit box after use.

I think the first choice might help the net code since I won’t be making so many instantiation calls at once. The second option might be a bit more complicated to deal with and lead to some complication issues and a lot of true-false validation for the moves.

Thank you for any advice!

It sounds like you’re already leaning toward the first option. It’s a little more work up-front, but also sounds like it could run faster and might be easier to debug.

As still another option, what about using trigger colliders to manage the whole thing? At that point, you don’t even have to enable/disable them, and you can just check if a particular trigger should be “hot” for the current attacks.