HitBoxComponent - acrimi/Raven GitHub Wiki
HitBoxComponent
defines one more hitboxes that will be attached to an entity. Hitboxes deal damage to any entity that has a HurtBoxComponent with intersecting hurtboxes. The configuration can range from single static hitboxes to complex, orientation-aware, time-based sequences of multiple hitboxes.
Configuration
When used inside the components
block, the initial state of the component can be configured with the following parameters:
Key | Type | Description |
---|---|---|
knockback | float | An optional force to apply to entities that are hit by any boxes in this component. Defaults to 0 , but the DamageSystem can specify its own default knockback. |
knockbackTimeFrame | float | The time, in seconds, that knockback will be applied to hit entities. The knockback force isn't applied through the PhysicsSystem, but is integrated immediately by the DamageSystem using this duration. Defaults to 1/60th of a second. |
boxes | object[] | An array of hitbox configurations that will be applied by this component. If only one hitbox is defined, this key can be omitted and the hitbox configuration can be defined as the top level object, including the knockback and knockbackTimeFrame keys. |
damage | int | The amount of damage this hitbox inflicts on entities it hits |
hitCode | int[]|int | One or more hit codes that will be assigned to this hitbox |
mirrored | boolean | Whether or not the left/right sequences should be mirrored around the entity's horizontal axis when the opposite direction is missing. This can help avoid creating redundant configurations for each direction. |
sequence | object[] | A sequence of positions and sizes that this hitbox will cycle through while it's attached. If this hitbox has only one state, this key can be omitted and the configuration can be passed directly to the top level hitbox object. This will be the default sequence for any orientations without explicit configurations. |
x | float | The left position of the hitbox at this step of the sequence, relative to the entity's left position |
y | float | The bottom position of the hitbox at this step of the sequence, relative to the entity's bottom position |
width | float | The width of the hitbox at this step of the sequence |
height | float | The height of the hitbox at this step of the sequence |
duration | float | The time, in seconds, that the hitbox will be in this position before moving to the next in the sequence. |
left | object[]|object | A sequence of positions and sizes that this hitbox will cycle through while it's attached and the entity is facing left. If the hitbox has only one state in this direction, the configuration can be passed directly and the array structure can be omitted. See sequence for the supported properties. |
right | object[]|object | A sequence of positions and sizes that this hitbox will cycle through while it's attached and the entity is facing right. If the hitbox has only one state in this direction, the configuration can be passed directly and the array structure can be omitted. See sequence for the supported properties. |
down | object[]|object | A sequence of positions and sizes that this hitbox will cycle through while it's attached and the entity is facing down. If the hitbox has only one state in this direction, the configuration can be passed directly and the array structure can be omitted. See sequence for the supported properties. |
up | object[]|object | A sequence of positions and sizes that this hitbox will cycle through while it's attached and the entity is facing up. If the hitbox has only one state in this direction, the configuration can be passed directly and the array structure can be omitted. See sequence for the supported properties. |
Examples:
"HitBoxComponent": {
"knockback": 100000,
"knockbackTimeFactor": 0.02,
"damage": 2,
"hitCode": 1,
"x": 0,
"y": 0,
"width": 16,
"height": 16
}
"HitBoxComponent": {
"knockback": 100000,
"knockbackTimeFactor": 0.02,
"damage": 2,
"hitCode": [
1,
2
],
"sequence": [
{
"x": 0,
"y": 0,
"width": 16,
"height": 16,
"duration": 0.2
},
{
"x": -8,
"y": -8,
"width": 32,
"height": 32,
"duration": 0.2
}
]
}
"HitBoxComponent": {
"damage": 2,
"mirrored": true,
"left": [
{
"x": 0,
"y": 0,
"width": 16,
"height": 16,
"duration": 0.2
},
{
"x": -8,
"y": -8,
"width": 32,
"height": 32,
"duration": 0.2
}
],
"up": {
"x": 0,
"y": 0,
"width": 16,
"height": 16
},
"down": {
"x": 0,
"y": 0,
"width": 16,
"height": 16
}
}
"HitBoxComponent": {
"knockback": 100000,
"knockbackTimeFactor": 0.02,
"boxes": [
{
"damage": 2,
"hitCode": 1,
"x": 0,
"y": 0,
"width": 16,
"height": 16
},
{
"damage": 1,
"hitCode": [
1,
2
],
"x": -8,
"y": -8,
"width": 32,
"height": 32
}
]
}
"HitBoxComponent": {
"boxes": [
{
"damage": 2,
"x": 0,
"y": 0,
"width": 16,
"height": 16
},
{
"mirrored": true,
"damage": 2,
"hitCode": [
1,
2
],
"sequence": [
{
"x": 0,
"y": 0,
"width": 16,
"height": 16,
"duration": 0.2
},
{
"x": -8,
"y": -8,
"width": 32,
"height": 32,
"duration": 0.2
}
],
"left": [
{
"x": 0,
"y": 0,
"width": 16,
"height": 16,
"duration": 0.2
},
{
"x": -8,
"y": -8,
"width": 32,
"height": 32,
"duration": 0.2
}
],
"up": {
"x": 0,
"y": 0,
"width": 16,
"height": 16
}
}
]
}
Properties
This component has no exposed properties