- Home /
Audio Clip constantly play
Hey guys, Ive got Pickups around the scene which have a sound script attached to them. when I play the game, all the sounds are playing straight away, how do I stop that from happening and only playing the sound when player picks it up.
using UnityEngine;
using System.Collections;
public class PlaySound : MonoBehaviour
{
public AudioClip pickupSound;
void OnTriggerEnter(Collider Other)
{
AudioSource.PlayClipAtPoint(pickupSound, gameObject.transform.position);
//audio.Play();
}
}
Comment
Answer by rutter · Nov 20, 2013 at 02:16 AM
You'll need to change two settings on each AudioSource:
Loop: if true, the audio will loop; if false, it will play once and stop
Play On Awake: if true, the audio will play automatically as soon as it exists; if false, it will wait until something tells it to play
Depending on your workflow, it may be easier to change these fields in the Inspector or in a script. You can do either just fine; it's just a question of which is simpler for you.
Your answer
![](https://koobas.hobune.stream/wayback/20220613122243im_/https://answers.unity.com/themes/thub/images/avi.jpg)