- Home /
3D audio not working on trigger
Hey So I've been trying to play a sound on trigger when my third person character walks through a gameObject. The third person character is tagged as "Player" and the gameObject is set to "is trigger" Moreover, i have an audio source attached to my gameObject and have also added the audio into my scene. I have tried a million other things for the past 2 weeks but nothing seems to be working till now. Below is the C# script I'm using:
using UnityEngine; using System.Collections;
public class test : MonoBehaviour {
public GameObject Sound;
// Use this for initialization
void Start () {
Sound.SetActive(false);
}
void OnTriggerEnter(Collider col)
{
if (col.gameObject.tag == "Player")
{
Sound.SetActive(true);
}
}
}
Can someone please give a step-by-step guide as to how i can play the audio when my character walks through the gameObject with the collider and the collider being set to "is trigger". Also, please let me know if i need to make any changes to the script. Thanks