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, Contact & Custom Integration

For all technical assistance, bug reports, asset configuration help, and general support, please reach out via email using the Contact Form. This is the primary and most reliable way to get help with any problems you encounter with the packages.

You can also use this form to inquire about custom freelance technical art services. If your project requires external 3D models to be integrated into the DPT ecosystem—including bespoke vertex-data packing, procedural wood grain mapping, GPU wind systems, or game-ready LOD budgeting—get in touch to discuss your specific needs and availability.

Email Contact (Preferred for all Support):
For troubleshooting, bug reports, publisher licensing, and freelance inquiries, please use the Contact Form on the DPT Games Hub.
DPT Community Discord:
While the contact form is the best way to get direct help with issues, you are also welcome to join the Discord Server to share feedback and connect with other users.