Question by
combat__wombat · Nov 19, 2015 at 12:28 PM ·
scripting problemaudionoob
Playing an audio clip on trigger entry - Help please
Im trying to play an audio clip when I enter a sphere collider and do not have the scripting knowledge to figure out why it isn't working
Here's my code - Csharp
using UnityEngine; using System.Collections;
public class playaudio : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter (Collider other)
{
if (other.gameObject.tag == "Player")
{
GetComponent<AudioSource>();
audio.Play();
Debug.Log("Played sound");
}
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612045649im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Troubleshooting Footstep Audio 0 Answers
show textwindow on mouseclick 0 Answers
Can't play shoot sound 0 Answers
How to stop a sound playing once another starts? (C#) 1 Answer