x


How to switch to next level after completeing the task in current level

Hi dudes, I am designing a game with 3 Levels for example if we have 10 enemies in our first level and once its completed we have to switch to the next level and so on. Here my doubt is in coding part once i complete my task by destroying my enemies in Level 1 how can jump to next level in this also i can load my next level by using "Application.LoadLevel("name of scene")" but the thing is how to identify that my enemies are destroyed and to loaded the next level automatically Please help me

more ▼

asked Apr 01 '11 at 07:23 AM

guru gravatar image

guru
1 1 1 1

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

3 answers: sort voted first

hey,

Do you have all those levels in different scenes. if you have it as different scenes means first add all those scenes when you build the project. when you hit build it shows a button name as ADD CURRENT.first you just hit it and add all those levels of your project.after you add this it'll appear like this,

Scene1 Name - 0 Scene2 Name - 1 Scene3 Name - 2

you'll get like this,if you want to move 2nd scene after killing those enemies means just use Application.LoadLevel(1), and move 3rd scene means use Application.LoadLevel(2).

see this link http://unity3d.com/support/documentation/ScriptReference/Application.LoadLevel.html

if you're not using different scene you cant use Application.LoadLevel.

Simple and enjoy.

more ▼

answered Apr 01 '11 at 07:33 AM

sriram90 gravatar image

sriram90
460 33 37 47

Thank you Buddy ! My doubt is that how to detect that my enemies are destroyed so that once its detected it has to load next level

Apr 05 '11 at 07:01 AM guru

just use counts....consider you're having 10 enemies when game get start...decrease that count when enemies destroy...finally if you got count 0 means move to next level...thats it...easy to make the code...

Apr 06 '11 at 08:39 AM sriram90
(comments are locked)
10|3000 characters needed characters left
         // Loads the level with index 0

           Application.LoadLevel (0);




          // Load the level named "HighScore".

           Application.LoadLevel ("HighScore");

This function loads level by its index. You can see the indices of all levels using the File->Build Settings... menu in Unity. Before you can load a level you have to add it to the list of levels used in the game. Use File->Build Settings... in Unity and add the levels you need to the level list there.

more ▼

answered Apr 01 '11 at 07:41 AM

robertmathew gravatar image

robertmathew
571 35 39 51

Thank you Buddy ! My doubt is that how to detect that my enemies are destroyed so that once its detected as my enemies in level 1 are completely destroyed it has to load next level

Apr 05 '11 at 07:03 AM guru
(comments are locked)
10|3000 characters needed characters left

Well, in order to detect when all the enemies are destroyed (in order to load the next level), you'll need to keep some kind of counter to keep track of how many enemies are left. That way, when the counter reaches zero, you know you have no enemies left, and you can advance to the next level.

I recently gave an answer to a very similar question here. Since the script is almost exactly what you need, just replace "cannon" with "enemy" and you should be good to go. Oh, and you'll also need a way to keep track of what level you're on, so you that you can advance to the next one.

more ▼

answered Apr 01 '11 at 11:05 AM

e.bonneville gravatar image

e.bonneville
5.7k 100 116 165

Thank you Elliot Let me try with this and if i have any doubt i will get back to you .

Apr 05 '11 at 07:04 AM guru
(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:

x298
x66

asked: Apr 01 '11 at 07:23 AM

Seen: 1841 times

Last Updated: Apr 01 '11 at 07:23 AM