Why Do People Use Separate Hitbox Objects?

For platformers, there are a few different reasons to use separate collision mask objects:

  1. The platformer character behavior doesn’t care what shape your collision mask is. It takes the widest point and the tallest point to make a rectangle, and uses that for all collision calculations. This is to ensure it doesn’t run into weird stuttering on slopes and other issues. (This is also why you should never change the width/height of your collision mask objects if you can avoid it, otherwise you could end up in part of a wall and cause oddities)
  2. By having a separate collision object with the platformer behavior on it, you can do a bunch of stuff to your animation and not have it impact your movement. Want to ensure that getting touched on the shoulder is a full hit? Put the collision mask of your actual visual sprite to be only in the rectangle shape you want, and only test against that for damage attacks. This would be separate from your movement collision mask (from the hitbox object), so your character doesn’t clip into walls visually.

There are others, but these are the most common for me.

3 Likes