Should the sword be part of the player sprite and therefore share the same hitbox that is widened when attacking?


Should the attack animation be separate from the player sprite therefore having its own hitbox?

To illustrate:

illustration of the two approaches

What would you recommend and why? What are the pros and cons of each?

  • 1
    \$\begingroup\$ The hitbox used for collision-testing does not need to have anything to do with the bounds of the image. These can be completely independent pieces of data. A single sprite can have an unlimited number of hitboxes, if you find it more convenient to animate this as a single image. \$\endgroup\$
    – DMGregory
    Dec 25, 2022 at 4:14
  • 1
    \$\begingroup\$ And it as well depends on how many different weapons your game has. When you have 50 weapons and each of them need to be drawn with the player attached to them, you might find it easier to have the player as its own sprite \$\endgroup\$
    – Zibelas
    Jan 3, 2023 at 11:54
  • \$\begingroup\$ Also consider whether your sword art is always one kind of sword or if you plan to have multiple versions of the sword. It will be a lot more work and consume more texture memory to have the sword as part of the character sprite. \$\endgroup\$
    – Romen
    Jan 3, 2023 at 17:39

1 Answer 1


It is usually favourable to separate the collision hit boxes to allow for independent collisions.

For example, did the sword hit the target or did the target hit the player?

For single player games, the former is always true. In multiplayer, timing is key.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .