- Home /
Audio Playing upon death
I'm new to scripting and i'm making an FPS. I'm trying to get my game to play an audio file (the entire audio file) when my character dies, then when the file finishes playing, i want the character to respawn.
Can anyone help me out with the source code?
Thanks,
Answer by lhk · Oct 24, 2010 at 12:39 PM
You could look how long your audio file plays and use Invoke to let your player respawn after the file is finished. Here is some c#
public AudioClip deathmelody;
public float length;
void OnDeath(){
audio.PlayOneShot(deathmelody);
Invoke("Respawn",length)
This is what the Scripting manual says to Invoke
function Invoke (methodName : string, time : float) : void
Description
Invokes the method methodName in time seconds.
Your answer
Follow this Question
Related Questions
Some audio does not play on Windows build but works perfectly in editor and on Mac 1 Answer
[NoBraves] Sound makes lag 1 Answer
Audio issue - Trying Waitforseconds 0 Answers
Play "Fail Laugh" on Respawn 3 Answers
Audio not playing! 0 Answers