Aego Русский

Hurtbox 2D

Area where hitboxes damage a Health: on this node or on its nearest parent with Health.

component gameplay.Hurtbox2D
On this page

Try it

Scale damage with a hurtbox

The red attack deals 2 base damage where it overlaps the green target. Multiplier 0 prevents that hit from reducing its 10 health points.

Set Multiplier to 2. The scene restarts and the real hit deals 4 damage: the target has 6 health points and turns orange. Reset restores the zero multiplier.

Starts the scene; open the example parameters to experiment.
Open in AegoDownload example project
Scene3 nodes
Attack
Transform
position[-1.4, 0]rotation0scale[1, 1]
Sprite Renderer
spriteTextureasset("ae900000000000000000000000000010")tintColor#ef4444ffsizeVec2[1, 1.5]orderint1
Hitbox 2D
areaRect[-0.5, -0.75, 1, 1.5]damageint2teamint1policyenumoncePerActivationactivebooltrue
Target
Transform
position[0, 0]rotation0scale[1, 1]
Sprite Renderer
spriteTextureasset("ae900000000000000000000000000010")tintColor#0dcc40ffsizeVec2[2.4, 2]
Hurtbox 2D
areaRect[-1.2, -1, 2.4, 2]multiplierfloat0activebooltrue
Camera
Transform
position[0, 0]rotation0scale[1, 1]
Camera 2D
zoomfloat40clearColorColor#111827ffscaleenumfitVirtualvirtualVec2[960, 540]activebooltrue
Scriptmain.aes
package demo

// The target changes color only after its actual Health takes damage.
script DamageIndicator {
    func Update(dt float) {
        hp := node.Get<Health>()
        if hp.Current < hp.Max {
            node.Get<SpriteRenderer>().Tint = Color{1, 0.5, 0.05, 1}
        } else {
            node.Get<SpriteRenderer>().Tint = Color{0.05, 0.8, 0.25, 1}
        }
    }
}

Fields

NameTypeDefaultDescription
AreaRect(-0.5, -0.5, 1, 1)

Rectangle in this node's space.

Shapeenumbox

box uses the rectangle; circle uses the circle inside it.

one of: box, circle
Multiplierfloat1

Damage taken here is multiplied by this, for weak spots and armour.

≥ 0
Activebooltrue

Off ignores hits.

HealthNodeRefnone

Health that takes the damage. Empty uses this node or its nearest parent with Health.