codeAPI Reference
s&box SelfCollisionSound: Single-surface collision sounds
SelfCollisionSound Component API Reference
SelfCollisionSound is a Component that plays collision sounds only from this object's surface, preventing duplicate sounds from both impacting surfaces. Implements ICollisionListener.
Type Signature
CSHARP
public sealed class SelfCollisionSound : Component, Component.ICollisionListener
{
public void Play(PhysicsShape shape, Surface surface, in Vector3 position, float speed);
}Methods
Play(PhysicsShape shape, Surface surface, in Vector3 position, float speed)
Plays the collision sound from the specified surface. Only plays if speed >= 50 and surface is valid.ICollisionListener Implementation
- OnCollisionStart(Collision collision) - Calls Play with collision.Self.Shape, Surface, Contact.Point, and NormalSpeed.
Behavior
In OnStart:
- Disables default collision sounds on all Rigidbody components (EnableCollisionSounds = false)
Usage
CSHARP
// Add to GameObject to prevent duplicate collision sounds
GameObject.Components.Create<SelfCollisionSound>();Notes
- Prevents duplicate collision sounds by disabling default sounds
- Only plays sounds from this object's surface
- Minimum speed threshold of 50 units/s
- Sealed class (cannot be inherited)
- Useful for props where you want single collision sounds
Was this helpful?