Search Unity

Collision Detection goes to Win Screen

Discussion in 'Scripting' started by manilamerc, Nov 27, 2012.

  1. manilamerc

    manilamerc

    Joined:
    Oct 4, 2012
    Posts:
    102
    When my character hits the door I want him to go to win Screen but I have no idea how. I copied and pasted a code from my Title screen that when I press Play it goes into the game. But I don't know how to track "if character hits door go to next screen".

    Here is my code:

    Here is my backdoor with a rigid body





    Here is my Win Screen
     
  2. Codetastic

    Codetastic

    Joined:
    Aug 13, 2012
    Posts:
    23
    The method for loading new scenes in Unity is Application.LoadLevel (there are however other loading methods that I wont get into here). To use Application.LoadLevel you need to supply it with ether a int or a string; where the int would be the desired scenes number in the build settings and the string would be the desired scenes name. Like so:
    Code (csharp):
    1.  
    2. Application.LoadLevel(0); //loads the first scene
    3. Application.LoadLevel("MainMenu"); //loads the scene named "MainMenu"
    4.  
    I should note that the desired scene must be added to the list of scenes in the build settings before you are able to load it.