On this page
  1. Fields
    1. from

rmp::behavior::Hitbox

behavior #include <rmp/behavior.h> include/rmp/behavior.h:593
struct 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

FieldTypeDefaultWhat it is
damageint1

What one hit costs

hitsunsigned0xFFFFFFFFu

The layers it hurts; the collision layers decide who it touches

knockbackfloat0

The impulse that pushes the one hit away from it

destroy_on_hitboolfalse

Discarded after its first hit, landed or not: a bullet

once_per_targetboolfalse

Hits each object once at most: a sword's one swing

on_hitCallback<Object &, Object &>

(the hitbox, who it hurt), when the damage landed

oursstruct { … }

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 { .speed = 320 } stops compiling — which is the whole design. The name is the fence.

from

static Hitbox from(const MapObject &object)

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.