Skip to content

07_DeathFxHandlers — Death FX Handlers

Goal

Teach the difference between previewing death VFX and running the real HealthSystem death flow.

What This Scene Demonstrates

Selected target → HealthSystem lifecycle → HealthDeathEffectHandler → death FX / optional destroy.

This scene shows how a selected target with HealthSystem and HealthDeathEffectHandler can preview death visuals, run the real kill flow, revive, reset health, and optionally destroy the target after death.

PreviewDeathEffects is VFX-only. HealthSystem.Kill() is the real death-flow entry point.

What To Look For

  • Setup: The panel selects from configured targets and checks for HealthSystem and HealthDeathEffectHandler.
  • Death VFX: Offset and lifetime are configured through the handler API.
  • Preview FX: Runs death VFX without changing health, firing death events, or destroying the object.
  • Kill: Calls HealthSystem.Kill() and runs the real death lifecycle.
  • Revive / Reset HP: Revives a dead target or resets a live target to max HP.
  • Destroy On Death: Controls whether the object can be destroyed after death FX flow completes.
  • Events: Died and Revived events are listened to and surfaced as panel feedback.

Mental model: HealthSystem owns alive/dead state; HealthDeathEffectHandler owns presentation around death.

Sample Scope

This scene covers:

  • Selecting between multiple configured targets
  • Validating HealthSystem presence
  • Validating HealthDeathEffectHandler presence
  • Death VFX offset
  • Death VFX lifetime
  • Previewing death VFX without changing health
  • Running the real death flow through HealthSystem.Kill()
  • Reviving dead targets through HealthSystem.Revive()
  • Resetting live targets through HealthSystem.ResetToMax()
  • Destroy-on-death toggle through the handler
  • Died and Revived event feedback
  • Fallback target selection if the current target is destroyed

This scene does NOT cover:

  • Damage rules
  • Shields
  • Respawn systems
  • Pooling systems
  • Reward logic
  • Production camera/audio/VFX pipelines
  • Networking implementation
  • Automatic handler creation

Some sample targets may include extra presentation listeners such as camera shake or time slow. Those are sample additions reacting to the same death flow, not required parts of HealthDeathEffectHandler.

Authority Note

This scene may include a permissive sample authority setup where mutations are allowed locally for demonstration purposes.

Networking Reminder

No networking is included; integration is the developer’s responsibility.

How To Use

  1. Enter Play Mode.
  2. Open the Setup tab.
  3. Select a target from the target selector.
  4. Confirm the selected target has:

  5. HealthSystem

  6. HealthDeathEffectHandler
  7. Check:

  8. current target name

  9. dead state
  10. destroy-on-death state
  11. Open the Death VFX tab.
  12. Adjust Offset to move the spawned death VFX relative to the target.
  13. Adjust Lifetime to control how long spawned VFX remains before cleanup.
  14. Open the Actions tab.
  15. Select the target again if needed.
  16. Toggle Destroy On Death:

  17. Enabled: object may be destroyed after death FX flow completes

  18. Disabled: object remains and can be revived in place

  19. Click Preview FX to preview visuals only.

  20. Click Kill (run flow) to call HealthSystem.Kill() and run the real death flow.
  21. Click Revive / Reset HP:

  22. If the target is dead, it calls HealthSystem.Revive()

  23. If the target is alive, it calls HealthSystem.ResetToMax()

  24. Watch the result messages for Died and Revived event feedback.

Failure Behaviour

  • No Targets

  • Meaning: The panel has no configured target list.

  • Fix: Populate the Targets array with at least one target.

  • Missing Selection

  • Meaning: No valid target is selected.

  • Fix: Add targets or select a non-null entry.

  • Missing HealthSystem

  • Meaning: The selected target cannot run death lifecycle actions.

  • Fix: Add HealthSystem to the target or select another target.

  • Missing DeathEffectHandler

  • Meaning: The selected target cannot preview or run handler death FX.

  • Fix: Add HealthDeathEffectHandler to the target.

  • Death VFX Blocked

  • Meaning: Death VFX controls need a target with both required components.

  • Fix: Return to Setup and fix the target binding.

  • Actions Blocked

  • Meaning: Runtime actions need a valid target with HealthSystem and HealthDeathEffectHandler.

  • Fix: Return to Setup and fix the target binding.

  • Preview FX does not change health

  • Meaning: This is expected; preview is VFX-only.

  • Fix: Use Kill (run flow) if you want the real death lifecycle.

  • Target destroys itself

  • Meaning: Destroy On Death was enabled and the death flow removed the object.

  • Fix: Select another valid target or disable Destroy On Death for repeat revive testing.

  • Revive / Reset HP selects another target

  • Meaning: Current target is missing or destroyed.

  • Fix: Use the newly selected valid target or repopulate the Targets array.

Behind The Scenes

  • HealthSystem — owns alive/dead state and lifecycle calls
  • HealthSystem.Kill() — real death-flow entry point
  • HealthSystem.Revive() — revives a dead target
  • HealthSystem.ResetToMax() — restores HP to max when target is alive
  • HealthSystem.Died — event surfaced by the panel when death occurs
  • HealthSystem.Revived — event surfaced by the panel when revive occurs
  • HealthDeathEffectHandler — handles death FX configuration and optional destroy behaviour
  • HealthDeathEffectHandler.ConfigureDeathVfx(...) — updates VFX prefab, offset, and lifetime settings
  • HealthDeathEffectHandler.PreviewDeathEffects() — previews VFX without changing health state
  • HealthDeathEffectHandler.SetDestroyOnDeath(...) — updates destroy-on-death behaviour
  • DeathVFXOffset — current VFX spawn offset
  • DeathVFXLifetime — current VFX lifetime
  • DestroyOnDeath — current destroy-on-death state

The panel uses public HealthSystem and HealthDeathEffectHandler APIs only. It does not access internals, use reflection, or fake death/revive events.

Key Takeaway

Preview FX is visual-only. Kill runs the real HealthSystem death flow.

HealthSystem decides whether the target is alive or dead. HealthDeathEffectHandler decides what presentation happens around that death moment.

That separation lets death feedback stay modular without stuffing presentation logic into the core health component.