0

I have been busy making a 2D game for the past month and am really happy with the way it has turned out... However my destroyer (collider) to end the level and send me to my other level which has the info on score etc isn't working how I would like it to..

Here the script on the Destroyer:

using UnityEngine;
using System.Collections;

public class EndGameDestroyer : MonoBehaviour {

    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Player") {
            Application.LoadLevel(2);
            return;
        }       
    }
}

Im using C# btw

Currently I run through the level and see the Destroyer in the background but then it just disapears and doesnt end the level. Please help as I am showing my game to the public at a games expo my college is running tommorow...

Thanks in advance :D

George Howarth
  • 2,767
  • 20
  • 18
user3799402
  • 1
  • 1
  • 1

2 Answers2

0

Have you added the scene for level 2 to your build? If not you need to go to your build settings while in your level 2 scene and press "add current" below the scenes in build box. Then go back to whatever scene you were in previously to get to the trigger and see if that works.

mhillsman
  • 770
  • 1
  • 8
  • 26
0

first maybe you need to check is your player already in "player" tag

second i suppose your scene name 2

open your scene 2 and then file>Builds Settings and see if your scene 2 is listed in the scene list and checked if not then just click add current

and then

Application.LoadLevel("2");

it need string

PamanBeruang
  • 1,531
  • 5
  • 27
  • 64
  • Well, it does not always need a string. You can pass as a parametr index of level (int) or name of the level (string). static void LoadLevel(int index); static void LoadLevel(string name); – Mad Jul 04 '14 at 12:48
  • oh sorry i didn't know that... all this time i'm using string XD – PamanBeruang Jul 04 '14 at 13:50