22 lines
460 B
C#
22 lines
460 B
C#
using UnityEngine;
|
|
|
|
public class TrashSound : MonoBehaviour
|
|
{
|
|
private AudioSource src;
|
|
|
|
private void Start()
|
|
{
|
|
src = GetComponent<AudioSource>();
|
|
}
|
|
|
|
private void OnCollisionEnter(Collision collision)
|
|
{
|
|
//if collision is not equal to Ignore Raycast Layer play the sound
|
|
if (collision.gameObject.layer == LayerMask.NameToLayer("Ignore Raycast"))
|
|
{
|
|
return;
|
|
}
|
|
src.Play();
|
|
}
|
|
}
|