Code, events and your own UI

Namespace RareGeometry.ResponsiveFX. Everything below is public and documented in the code.

Hitting #

HitFeedback.Hit(target, 25);                                   // GameObject or any Component (a collider you hit)
HitFeedback.Hit(target, new HitInfo(25, HitKind.Critical)
    .At(hitPoint).From(direction).By(attacker).Killing(isKill));
var report = hitFeedback.Play(hitInfo);                        // what played and why
hitFeedback.Freeze(0.1f);                                      // a target-only freeze by itself
hitFeedback.StopAll();                                         // stop everything running on it and put it back

Events #

Event When
HitFeedback.AnyHit (static) Every hit on any target: your combo counter, achievements, logs.
hitFeedback.Played Every hit on this target, with its report.
OnHit (UnityEvent with the amount), OnKilled In the inspector, no code.
Health.OnDamaged, OnHealed, OnDied, Changed Health changes.

Your own health #

public class MyHealth : MonoBehaviour, IHealthSource
{
    public float hp = 100, maxHp = 100;
    public float CurrentHealth => hp;
    public float MaxHealth => maxHp;
    public float CurrentShield => 0;
    public float MaxShield => 0;
}

Your own number display (TextMesh Pro, UI Toolkit) #

public class MyNumbers : MonoBehaviour, IDamageNumberDisplay
{
    void OnEnable() => DamageNumbers.CustomDisplay = this;
    void OnDisable() { if (DamageNumbers.CustomDisplay == (IDamageNumberDisplay)this) DamageNumbers.CustomDisplay = null; }

    public int Show(Vector3 worldPosition, string text, HitKind kind, Color color, float sizeInPixels, Sprite icon, int combineWith, HitFeedback owner)
    {
        // Spawn your TextMeshPro popup here. The text is ready: "1.2K", "+25", "Miss".
        return 0;
    }
}

Your own display gets a string per number (Responsive FX's own numbers make none).

Your scripts in hitstop #

public class MyAI : MonoBehaviour, IHitstopReceiver
{
    bool frozen;
    public void OnHitstop(bool isFrozen) => frozen = isFrozen;
    void Update() { if (frozen) return; /* ... */ }
}

Global settings, time and the screen #

HitFeedbackSettings (accessibility, master juice, volume, rumble, camera, Translate for your localisation), TimeControl.Request(scale, seconds) and StopAll() (safe slow motion), ScreenFlash.Play(color, amount), DamageNumbers.Show / ShowText / Clear / Hidden / Prewarm, HitFeedbackOverlay.Visible (hide the screen layer behind your menus) and HitCameraShake.For(camera).AddTrauma(amount, settings).

Multiplayer #

Feedback is local to each player's screen, so there is nothing to sync: play the hit on every client from your own networked event (an RPC or a synced health change). With Netcode for GameObjects, call HitFeedback.Hit in the ClientRpc (or OnValueChanged of a health NetworkVariable) that tells clients about the hit.

Performance #

Numbers, bars and the player's screen effects are drawn in a few batched calls. Hits, numbers and bars make no garbage in steady play (checked by Responsive FX's tests and in built players). Call DamageNumbers.Prewarm() while loading to make the number pool up front.

Something unclear or wrong? Tell us · Get help