Search Unity

Load Level Script

Discussion in 'Scripting' started by SlenderBoy302, Apr 13, 2018.

  1. SlenderBoy302

    SlenderBoy302

    Joined:
    Apr 23, 2017
    Posts:
    7
    Hello, I'm currently developing my own survival horror game from scratch. I'm having a Issue with C# script. I'm new to C#. I some screenshots. The Script is the Load Level. I've been stuck on it for days. and the other screenshots is the setup I had. Scene Switch.PNG Inspector.PNG Scene Trigger.PNG End Chapter.PNG I want the player to hit the trigger to switch to the Credits level. (The game i'm developing is "The Lost Neighbor" . The Assets I used in the level screenshot is part of the demo and the future I'm removing them and replacing it with my own)
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    MonoDevelop is pointing out you have a script error on line 7. You have two opening parentheses, but only one closing. There should always be an equal number of opening and closing parentheses, brackets, etc.

    Also, Application.loadlevel was replaced by SceneManager.LoadScene years ago. I'm not even sure if Application.loadlevel is still included in Unity, but you should switch to the new one regardless. You should also check that it is actually the player that has entered the trigger collider before switching scenes. Otherwise the way you have it now it will switch scenes if anything with a collider crosses the trigger.

    Lastly are you sure your player is even hitting that thin trigger collider you have there? Why make it so skinny and high up? Your player might just be going under it.
     
    Kiwasi likes this.
  3. SlenderBoy302

    SlenderBoy302

    Joined:
    Apr 23, 2017
    Posts:
    7
    I just noticed it. I removed it and re-added in. I'm not sure what the exact size of the trigger event.