x


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,

more ▼

asked Oct 24, 2010 at 11:08 AM

Brandon 5 gravatar image

Brandon 5
11 6 4 5

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Oct 24, 2010 at 12:39 PM

lhk gravatar image

lhk
610 41 31 42

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1696
x1640
x837
x351
x278

asked: Oct 24, 2010 at 11:08 AM

Seen: 1805 times

Last Updated: Oct 24, 2010 at 11:08 AM