WeaponHitboxComponent - UQdeco2800/2021-studio-2 GitHub Wiki
WeaponHitboxComponents are the same as normal hit-boxes with a few key differences:
- Weapon hit-boxes can be resized at run-time. This is done by destroying & resetting the fixture.
- They are positioned relative to the entity, using constants defined in
MeleeWeapon.java - They aren't set by default, i.e. the create() function doesn't set the fixture.
Setting
Weapon hit-boxes can be set using the set() method. This method takes two parameters:
size- A vector that represents the attack width & range of the weapon, as x & y components. The size is relative to the entity.direction- The direction of the hit-box, relative to the entity. Must be one of the five constants defined in MeleeWeapon.java
Example

Using the above example, this gives:
Attack width= 1 (1 * entity's width)Attack range= 0.5 (0.5 * entity's height)Direction= MeleeWeapon.RIGHT

Destroying
Weapon hit-boxes can be destroyed simply using

Notes
- Although every melee weapon requires a weaponHitboxComponent on its owner entity, that relationship is not bi-directional.
- i.e. you can have an entity that has a weaponHitboxComponent, but not a meleeWeapon. This becomes useful for things such as AOE attacks, abilities, time-activated traps/explosions, and more.
Authors
This class was written by Jacob Edwards @jac0be