rmp::behavior::Hitbox
What hurts: a sword's swing, a spike, a bullet, an explosion. On touching an object with an rmp::behavior::Health on one of the layers it hits, it calls that Health's damage() — the invulnerable window, on_damage and the once-only death all apply — and pushes it away. A Health's hurt_by does not count an object with a Hitbox: the Hitbox is what decides, so nothing is hurt twice for one touch.
From the editor: "damage" (Int), "knockback" (Float).
Added to an object with add<rmp::behavior::Hitbox>(); the framework calls its _update, _collision with the object it is on.
Fields
| Field | Type | Default | What it is |
|---|---|---|---|
damage | int | 1 | What one hit costs |
hits | unsigned | 0xFFFFFFFFu | The layers it hurts; the collision layers decide who it touches |
knockback | float | 0 | The impulse that pushes the one hit away from it |
destroy_on_hit | bool | false | Discarded after its first hit, landed or not: a bullet |
once_per_target | bool | false | Hits each object once at most: a sword's one swing |
on_hit | Callback<Object &, Object &> | (the hitbox, who it hurt), when the damage landed | |
ours | struct { … } | What it is keeping track of. Readable, because sometimes you want it; not yours to write. It is one PUBLIC member and not a private block because a struct with a private member is not an aggregate in C++20, and then |
from
A Hitbox with the fields the map's entity has by these names — damage, knockback — and the defaults for the rest. See "FROM THE EDITOR" at the top of this file.