3DPlatformer Tutorial - GameOverScript bug?

Hi,

I’ve been working through the 3DPlatformer tutorial and seem to have hit a problem - I don’t know if I’ve done something wrong or if there’s a bug.

When I add the GameOverScript to the GameOver scene’s Main Camera the Game Over scene immediately jumps to the Start Menu scene upon loading instead of waiting for a key press or the audio clip to finish.

Any ideas? I get no error messages in the console, and I’ve tried adding recreating the scene several times to no avail.

ade.

The script does indeed have a bug. It assumes that as soon as the audio clip is not longer playing, that means that it has FINISHED playing and should load the menu again.

It can ALSO mean that the clip has not started playing YET. It could be a useful exercise to figure out how to fix the script, but I can give you a solution if you’d like.

There was some discussion earlier as to whether this is really a bug in the behavior of the audio clip. I’m not convinced of that, but it IS a bug in either the tutorial of Unity =)

I thought that might be the issue, but am new to Unity.

I imagine there’s a few ways around the issue, but I fixed it by amending the script to:

var startedPlaying : boolean = false;
function Update ()
{
if (audio.isPlaying )
startedPlaying = true;
if ( (!audio.isPlaying startedPlaying == true) || Input.anyKeyDown)
Application.LoadLevel(“StartMenu”);
}

That looks pretty much exactly like what I did. I was in the same position as you about 3 weeks ago.