- Home /
3D audio source not playing on trigger
So i have a third person character with the tag "Player" Im trying to play an audio when the third person character walks through the gameObject.
I have tried everything that's out there. Im working on a C# script. Here is he script: 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);
}
}
}
I also have "is trigger" on on the gameObject and the audio file in my hierarchy attached to the gameObject. I also tried attaching it to the Main Camera but its still not working. Can someone please send a step by step process and improvement to my script for this to work. Im in desperate need of it, been working on it for 2 weeks now.
Your answer
Follow this Question
Related Questions
When Audio is played through script it buzzes and glitches 2 Answers
Audio Source wont play in if statement 3 Answers
AudioSource.clip.time won't work? 2 Answers
AudioSource.PlayOneShot playing loud and garbled 1 Answer
Dynamic Backgroundmusic 1 Answer