Skip to main content

TriggerImpactDetector

A class in Root.Township, Alta.Impact.

A trigger that raises an ImpactHit event when an ImpactTool enters it, for things that react to being hit through a trigger collider rather than a collision.

Constructors​

MemberWhat it is
TriggerImpactDetector()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

5 private and internal fields
MemberWhat it is
private ImpactChannel[] channelsImpact channels the hit is checked against.
private float minimumDamageA hit must do more health damage than this to count (default -1).
private float minimumEffectivenessA hit must be more effective than this to count (default 0.2).
private ImpactHitEvent onHitBacking field for OnHit.
private Dictionary<Rigidbody, HashSet<Collider>> trackedRigidbodiesRigidbodies inside the trigger and which of their colliders are in.

Properties​

MemberWhat it is
ImpactHitEvent OnHit { get; }Event raised with the hit when a tool enters the trigger.

Methods​

MemberWhat it is
void Clear()Forgets all rigidbodies inside the trigger, so the next entry counts as a new hit.
3 private and internal methods
MemberWhat it is
private void GenerateHit(ImpactTool tool, Collider collider)Asks the tool for its best hit on this trigger's channels and raises onHit if it is effective and strong enough.
private void OnTriggerEnter(Collider collider)On the first collider of a rigidbody entering, generates a hit if that rigidbody has an ImpactTool.
private void OnTriggerExit(Collider collider)Stops tracking a rigidbody once all its colliders have left.

Used in​

Members of other types that take, return or hold a TriggerImpactDetector: