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