# Hitbox 2D

> Aego 0.12.5 · development; docs build `4a32b816933e02930662f6a443cb25abe6050d090c55e237cbff5c44ae9b25f8`. [Build manifest](/docs-build.json).

```
component gameplay.Hitbox2D
```

Damages hurtboxes inside its area, once per target per activation, on every entry or periodically.

## Fields

| Name | Script name | Type | Default | Description |
|---|---|---|---|---|
| Area | `Area` | `Rect` | `(-0.5, -0.5, 1, 1)` | Rectangle in this node's space. |
| Shape | `Shape` | `enum` | `box` | box uses the rectangle; circle uses the circle inside it. |
| Damage | `Damage` | `int` | `1` | Damage per hit before the hurtbox multiplier. |
| Knockback | `Knockback` | `Vec2` | `(0, 0)` | Push on a hit: velocity in units per second for a Motion 2D target, impulse for a dynamic body. Turns with the node. |
| Knockback From Center | `KnockbackFromCenter` | `bool` | `false` | Pushes away from the hitbox centre instead, with the length of Knockback. |
| Team | `Team` | `int` | `-1` | Team of the attack; -1 takes the team of the nearest Health above. |
| Friendly Fire | `FriendlyFire` | `bool` | `false` | Also hits targets of the same team. |
| Policy | `Policy` | `enum` | `oncePerActivation` | onEnter hits on every entry, oncePerActivation hits each target once until Activate, periodic hits every Period while overlapping. |
| Period | `Period` | `float` | `0.5` | Seconds between hits for the periodic policy. |
| Active | `Active` | `bool` | `true` | Off deals no damage. |

## Activate

```
func (Hitbox2D) Activate()
```

Starts a new attack: targets hit before can be hit again.

## Deactivate

```
func (Hitbox2D) Deactivate()
```

Stops dealing damage.

## Pulse

```
func (Hitbox2D) Pulse()
```

Deals one round of damage in the next step, active or not.

## Hit

```
signal Hit(target NodeRef, damage int)
```

Fires for each target damaged.
