Hello ,
I have a problem with playing an audio clip when the object set to active .I want to get my object active when the player score reach 100 . Until here , everything worked great . So if the object has set to active , the sound should play . But it play with lag and too noisy sound!.
Here is my script :
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(AudioSource))]
public class ActiveGame : MonoBehaviour {
public Score scoreScript;
public float ScoreToEnable;
public AudioClip EnableSound;
public GameObject Desstroy;
// Use this for initialization
void Start () {
//Find Scripts GameObject, and get Score Component.
scoreScript = GameObject.Find ("Score").GetComponent<Score>();
}
// Update is called once per frame
void Update () {
if(scoreScript != null && scoreScript.score >= (ScoreToEnable))
Desstroy.gameObject.active = true;
if(scoreScript != null && scoreScript.score >= (ScoreToEnable))
audio.Play();
audio.Play(22050);
}
}
Please Note that : I’ve tried to use audioclip play at point , audio.play , and audio play oneShot . Nothing worked !.
Please Help !
Great answer sir ! :) Thank you :) .
– Amer_ALhwifi