Skip to main content

TriggerImpactTool

A class in Root.Township, Alta.Impact.

An ImpactTool that hits through a trigger collider instead of physics collisions, working out a contact point itself. Used for swings and other hits that should not push things.

Constructors​

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

Fields​

11 private and internal fields
MemberWhat it is
private LayerMask forcedContactLayers that always get a blunt hit even without a pickup or detector, like terrain.
private List<TriggerImpactTool.DelayedHit> frameHitsHits queued this frame, applied one frame later by RunDelayedHits.
private HashSet<HealthObject> hitHealthObjectsHealth objects already hit, when isHittingOncePerHealthObject is on.
private HashSet<Rigidbody> hitRigidBodiesRigidbodies already hit since the tool was last activated.
private List<ImpactDetector> ignoreDetectors this tool never hits.
private bool isActiveBacking field for IsActive.
private bool isHittingOncePerHealthObjectWhen on, the tool hits each health object only once, even through several colliders.
private bool isLockedForFrameSet after a fully blocking hit; further trigger entries are ignored until the queued hits run.
private Vector3 physicsPositionThe tool's position from the last fixed update.
private Collider thisColliderThe tool's trigger collider.
private IUnityUpdateMethod updateThe registered fixed update for UpdatePosition.

Properties​

MemberWhat it is
bool IsActive { get; set; }Turns the trigger collider and position tracking on or off; turning it on or off forgets what was already hit.

Methods​

MemberWhat it is
void OnTriggerEnter(Collider other)Works out a contact point for a pickup, detector or forced-contact layer, generates the hit and queues it for the detectors.
protected override void Awake()Sets IsActive and enabled from whether the trigger collider starts enabled.
4 private and internal methods
MemberWhat it is
private void OnDisable()Sets IsActive to false.
private void OnEnable()Sets IsActive to true.
private void RunDelayedHits()Applies this frame's queued hits to their detectors and unlocks the tool.
private void UpdatePosition()Fixed update that records the tool's last position, used as the hit origin.

Used in​

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