Question by
mullac51 · Feb 08, 2017 at 02:22 AM ·
audioaudiosourcedelayaudioplay
Delaying Audio with PlayedDelayed not working
I have attached this script to the Audio GameObject I want to delay but i don't get any delay.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DelayAudio : MonoBehaviour {
// Use this for initialization
void Start ()
{
AudioSource audio = GetComponent<AudioSource>();
audio.PlayDelayed(3);
}
}
Comment
Answer by Joeltron · Feb 08, 2017 at 02:43 AM
I have no idea why that isnt working as im not familiar with the audio api, but for timers and delayed calls, i like to use Invoke. Its really easy to set up.
void KillAudio(){
audio.Dont play anymore;
(pseudocode as im not familiar with audio, use whatever actually stops it)
}
void Start(){
Invoke("KillAudio", 3f);
}
At start, it will call the "KillAudio" method in 3 seconds.
Your answer
Follow this Question
Related Questions
play Audio Array in java 0 Answers
Audio playing at hightspeed and simoultanesly various times! 1 Answer
Trying to use audio causes errors when trying to use in an 'if' statement 1 Answer
Audio coming through iPhone earpiece 0 Answers
Can not play a disabled audio source, but the source is definitely not disabled! 0 Answers