I’m totally new to unity, but I started making some simple things. I have some regular programming knowledge, but I’m not very confortable with scripting. Could someone guide me through this?
I assume you mean a sound will begin once the user has been falling for X amount of time. Like this?
var source : AudioSource; /* put audio source in editor here. You need an Audio Source to play any sound, best to put it on your camera.*/
var clip : AudioClip; // put the audio clip you want to play in editor here.
var TimeSinceStart : float; //The time in seconds since the start of the game.
var TimeForSound : float = 5; //The time you want the sound to play.
function Start(){
TimeSinceStart = 0; // ensures the TimeSinceStart of game is 0 when the game starts.
}
function Update(){
TimeSinceStart += Time.deltaTime; /* adds the time the last frame took to execute to the time since start of the game. This will constantly count how many seconds since the start.*/
if(timeSinceStart>=TimeForSound){
source.PlayOneShot(clip); //play the audio "clip" through the "source"
}
}
Hope this is what you meant and I hope I helped you.