Skip to main content

CollisionImpulseReader

A class in Root.Township, Alta.Intelligence.

Component that turns strong collisions with rigidbodies into a 0 to 1 strength and passes it to an IReceiveImpulseFromCollision on the next frame.

Constructors​

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

Fields​

4 private and internal fields
MemberWhat it is
private float strongFlailVelocityImpulse at or above which strength is 1 (default 2).
private IReceiveImpulseFromCollision targetThe receiver, cast from targetObject in Awake.
private Object targetObjectSerialized reference to the object that receives the impulse.
private float weakFlailVelocityImpulse at or below which the collision is ignored (default 1).

Methods​

2 private and internal methods
MemberWhat it is
private void Awake()Casts targetObject to IReceiveImpulseFromCollision.
private void OnCollisionEnter(Collision collision)Ignores hits without a rigidbody or with impulse at most weakFlailVelocity; otherwise maps impulse between weak and strong to 0 to 1 and calls ReceivedImpulse later.