DPT_PlaySoundOnCollision

Component Reference Guide
A standalone, highly optimized utility component designed to handle physics impact audio loops for independent accessories, scattered debris chunks, or high-density loot drops without performance degradation or audio driver clipping.

Inspector Fields

Field Description
Collision Sounds An array pool of AudioClip profiles. The component picks an entry at random on an approved impact frame to prevent mechanical acoustic repetition.
Pitch Variance The dynamic range window added or subtracted from the default modifier (1.0) on playback execution to smoothly shift tone variance.
Velocity Threshold The mandatory impact magnitude threshold required to fire a sound. Higher properties stop clips from machine-gunning on soft slides or continuous resting jitters.
Local Cooldown The enforcement delay buffer (in seconds) tracking the specific instance before it is allowed to call another audio sequence.

Technical Architecture

Physics Layer Optimization (High Density)

When a container shatters or drops large volumes of loose items simultaneously, the physics engine can create dozens of mutual collision contacts on a single frame. While the script fast-escapes audio overhead, the main thread must still process raw physics messages. Implementing proper layer filtering drastically optimizes CPU scaling.

Recommended Optimization Steps:
  1. Navigate to your project layout settings and create a dedicated User Layer named Debris or Loot.
  2. Assign your fractured debris sub-meshes, accessory prefabs, or loose loot rewards to this newly created layer.
  3. Open the Unity preferences matrix via Project Settings > Physics.
  4. Scroll down to the bottom of the inspector window to find the Layer Collision Matrix checkbox grid.
  5. Locate the intersection point where your custom layer crosses itself (e.g., Debris vs Debris) and uncheck the box to disable intra-layer tracking.

This configuration ensures that dynamic debris pieces or loose items bypass mutual physical calculations entirely—preventing massive spikes in OnCollisionEnter messaging on the main thread—while still allowing them to drop naturally, bounce off environmental terrain, slide down flooring geometry, or cross trigger filters safely.

Troubleshooting Notes

"Audio drops or skips during intensive loot burst explosions"
This is a built-in optimization design path. When multiple physics instances settle on an identical frame boundary, the global frame-gate hard-throttles playback allocations to protect your game audio driver mixer pipeline from overloading.
"The object plays sounds rapidly when rolling down a slope"
Increase the Velocity Threshold step boundary to filter out soft friction states, or lengthen the Local Cooldown parameter window to expand the mandatory resting interval.

Support & Custom Pipeline Integration

If your project requires external or custom 3D models to be fully integrated into the DPT ecosystem—including custom vertex-data packing, procedural wood grain mapping, normal array configuration, advanced GPU wind system implementation, or any other bespoke features—freelance technical art services are available. Additionally, availability extends to general 3D asset production, high-to-low poly hard surface modeling, stylized prop creation, and game-ready LOD budgeting built to align cleanly with your specific project constraints.

Contact & Inquiries:
For freelance modeling contracts, custom asset optimization passes, standard package bug reports, and publisher licensing enquiries, please use the Contact Form on the DPT Games Hub.
DPT Support Discord:
For dedicated technical assistance, asset configuration help, and direct feedback on our Unity packages, join the Support Server.