Skip to content

DamageOnTouch

namespace Griff.Scenes;
public sealed class DamageOnTouch : Component

Hurts whatever with Health it touches, with no code: spikes, lava, enemies, bullets. Works on solid collisions and triggers, and keeps hurting while they stay touching (each hit still waits out the target’s InvincibleTime). Needs a collider on the same entity.

This is a component: its saved properties are on its component page.

public float Amount { get; set; }

How much health each hit takes.

public string? AmountRoll { get; set; }

Dice rolled for each hit in place of Amount, e.g. “1d8+2”; empty hits for Amount every time. Table Values sets it from a dice column given for Amount.

public bool DestroyOnHit { get; set; }

Destroy this entity when it touches something it can hurt, like a bullet or a one-hit kamikaze enemy.

public bool DestroyOnWall { get; set; }

Destroy this entity when it runs into a wall or anything else solid it can’t hurt: bullets, fireballs, arrows.

public bool Kill { get; set; }

Kill outright, invincible or not, whatever the Amount: bottomless pits, lava, crushers.

public float Knockback { get; set; }

How hard a hit pushes the target’s body away, in units per second. 0 doesn’t push.

public string? Layers { get; set; }

The collision layers it hurts, e.g. “Player” on spikes and enemies, “Enemy” on the player’s bullets. Empty hurts anything with health.

public bool Hurts(string? layer)

True if it hurts things on collision layer layer.

public float RollAmount()

The damage of one hit: AmountRoll rolled, or Amount.