Skip to main content

CollisionSoundEmitter

A class in Root.Township, the global namespace.

Plays the object collision sound at the contact point on a hit, with layer filtering and a short cooldown.

Constructors​

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

Fields​

3 private and internal fields
MemberWhat it is
private LayerMask ignoreLayersLayers that never make a sound.
private float ignoreMultipleHitsWithinSeconds after a sound during which hits are silent.
private float lastCollisionTimeTime of the last sound.

Methods​

1 private and internal method
MemberWhat it is
private void OnCollisionEnter(Collision collision)Plays SoundEffect.ObjectCollision at the contact unless the other layer is ignored or it's within the cooldown.