Hit Feedback and hitting things

Hit Feedback is the one component Responsive FX needs. Put it on anything that can be hit: an enemy, the player, a crate. Every hit then plays the whole reaction from its profile.

Hitting it #

Way How
One line of code HitFeedback.Hit(target, 25); finds the Hit Feedback on the target or its nearest parent, so passing the collider you hit works. Returns false when there is none (the debugger remembers it).
A full hit HitFeedback.Hit(target, new HitInfo(25, HitKind.Critical).At(point).By(attacker));
Responsive FX's Health health.Damage(25), health.Damage(hitInfo), health.Heal(10), health.Kill(). Feedback plays by itself.
UnityEvents and animation events Methods with one float: HitAmount, CriticalHit, HealAmount, ShieldHit, DamageOverTime, KillingHit. And Miss, Block, ShowStatus (string).
Directly GetComponent<HitFeedback>().Play(hitInfo) returns the hit's report.

HitInfo: one hit #

Field What it does
Amount The number shown.
Kind Normal, Critical, Heal, Shield, Miss, Block, DamageOverTime or Status. Each kind has its own look and strength.
IsKill (.Killing()) The killing blow: plays the kill moment.
Point (.At(point)) Where it landed: numbers (Hit Point anchor) and particles start there.
Direction (.From(dir)) or Source (.By(attacker)) Which way it travelled: knockback, camera punch and the player's damage arrow use it. Without either, Responsive FX pushes away from the camera.
Text A word instead of the number ("Stunned").
Icon An icon beside the number.
Strength Scales flash, shake, hitstop and knockback for this hit.

What each kind plays #

Kind Plays
Normal, Critical, Shield, Block Everything (criticals stronger, blocks softer).
Heal Number (green, with a +), flash, squash, bar, sound. No push, shake or freeze.
Damage over time Small combining numbers, a light flash, bar, sound. No freeze, shake or push.
Miss, Status The word and its sound only.

The component #

Setting What it does
Profile / Preset The feel. Without a profile asset the preset's shared profile is used; Save As Profile makes an asset you can change.
Juice (with a profile asset) More or less of everything.
Renderers to flash Empty: every mesh, skinned mesh and sprite under the object (lower LOD levels and children with their own Hit Feedback are skipped).
Visual (squash) What squashes and pops. Use a child when the root also moves or scales.
Number and bar anchor Where numbers and the bar appear. Empty: above the renderers.
Health source Your own health script (anything with IHealthSource). Empty: found on the object.
Overrides This object only: a strength, each part on or off, its own flash colour, its own Display as, a number offset, its own number colour and size, and its own floating bar style.
Events On Hit (amount), On Killed.

Preview in the inspector #

In Play Mode the Hit, Critical, Heal and Kill buttons play on the selected objects, and the inspector lists what the last hit played and why anything was skipped.

Something unclear or wrong? Tell us · Get help