x


Level couldn't be loaded because its not added to build settings, but it is?

Hey I am trying to make my menus work for when I die a game over screen appears and the player has the option to either restart or go to the main menu, however when I try to link the scenes together by putting Application.LoadLevel("1"); it doesnt work, it works when I put the name of the scene, however I am having a problem when I click restart, it goes to the game then goes back to the restart screen, if I press main menu from the restart screen then press play, it goes back to the restart screen even tho its linked to the game scene :S, which is really fustrating, I donno what I am doing wrong, thanks for your time in reading this I hope someone can help.

more ▼

asked Apr 23 '10 at 03:12 PM

GeneralGadd gravatar image

GeneralGadd
134 17 18 26

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

2 answers: sort voted first

Is "1" the name of your scene? If not, you load scenes based on build order by using the actual integer, ie

Application.LoadLevel(1);

provided the scene you're trying to load is labeled as number one in the build settings.

more ▼

answered Apr 23 '10 at 03:35 PM

burnumd gravatar image

burnumd
3.4k 22 35 71

that works but is there a way of loading the game from the start as it seems to be loading it where I died so when I press restart it goes back to the game over page

Apr 23 '10 at 04:57 PM GeneralGadd

Are you using a static variable or an object where DontDestroyOnLoad is true to determine whether a player is dead? If so, when you restart the scene, that state will be the same and you'll be telling the game to go back to the restart screen immediately.

Apr 23 '10 at 05:14 PM burnumd

I am using a static var but I have two scripts, one a health script and another thats lives

Apr 25 '10 at 12:50 PM GeneralGadd
(comments are locked)
10|3000 characters needed characters left

Application.LoadLevel has 2 forms; one takes an integer argument, which is the index of the level in the list, and the other form takes a string which is the level name. If you are passing 1 as "1", it will be looking for a level named "1", not the level at position 1.

more ▼

answered Apr 23 '10 at 03:34 PM

Molix gravatar image

Molix
4.8k 17 27 66

that worked however I am still having the same problems when I want to restart, it goes back to the same menu instead of the beginning of the game

Apr 23 '10 at 04:33 PM GeneralGadd

To explain fully, it works when I play the scenes indvidually, say if I load the game over scene it will load the reset button fine, however when I play the game and die the game over screen comes on however if I press restart it goes back to the game over screen not the beginning of the level

Apr 23 '10 at 04:35 PM GeneralGadd

Perhaps when you load the game over screen and restart you are not clearing the "die" variable, so when you hit restart you're already dead, and the game over loads.

Apr 24 '10 at 03:49 AM Molix

I have tried help on the forum that may explain my predicament better

http://forum.unity3d.com/viewtopic.php?p=307196#307196

Apr 25 '10 at 01:01 PM GeneralGadd
(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:

x109

asked: Apr 23 '10 at 03:12 PM

Seen: 3150 times

Last Updated: Apr 23 '10 at 03:19 PM