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?
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;
This is what the Scripting manual says to Invoke
function Invoke (methodName : string, time : float) : void
Invokes the method methodName in time seconds.
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
No one has followed this question yet.
Can't get my sound to work..
Play An Audio Clip When An Instantiated Object Collides
gameObject to play sound on deletion, won't work...
Play "Fail Laugh" on Respawn