public static void Spawn(Vector2 position, float rotation, Collider2D collisionSurface, bool playAudio) { // Using a collision surface, look for an appropriate CollisionSurface component in the parent. CollisionSurface surface = collisionSurface.GetComponentInParent <CollisionSurface>(); if (surface != null) { // Spawn effect, if present. HitEffectPreset effect = surface.GetHitEffect(); if (effect != null) { Spawn(position, rotation, effect); } // Now play audio using the settings on the CollisionSurface AudioClip c = surface.GetAudioClip(); if (c != null) { float volume = surface.GetVolume(); float pitch = surface.GetPitch(); float range = surface.GetRange(); float maxPanRange = surface.GetMaxPanRange(); float minPanRange = surface.GetMinPanRange(); float lowPassStart = surface.GetLowPassDistance(); AudioManager.Instance.PlayOneShot(position, c, volume, pitch, range, minPanRange, maxPanRange, lowPassStart); } } }