using System.Collections; using System.Collections.Generic; using UnityEngine; public class LidSound : MonoBehaviour { private AudioSource src; private void Start() { src = GetComponent(); } private void OnCollisionEnter(Collision collision) { //Check if the layer is named StopperLayer if (collision.gameObject.layer == LayerMask.NameToLayer("StopperLayer")) { //Play the sound src.Play(); } } }