Search Unity

Jumps Over Scenes

Discussion in 'Scripting' started by Hapciupalit, May 28, 2015.

  1. Hapciupalit

    Hapciupalit

    Joined:
    Apr 24, 2015
    Posts:
    103
    Does anyone know why sometimes I jump over scenes. The loading scene code is :

    Code (JavaScript):
    1. var levelToLoadString : String;
    2.  
    3. function OnTriggerEnter () {
    4.       Application.LoadLevel (levelToLoadString);
    5. }
    It Loads the scene and than Jumps To the next one;

    Every Scene got a door with this script and a Spawining Point with this code :

    Code (JavaScript):
    1.  
    2. function Start(){
    3.    
    4.     var player = GameObject.Find("Player");
    5.     var spawn_point = GameObject.Find("Spawn Point").transform.position;
    6.     player.transform.position = spawn_point;
    7.  
    8. }
    what could it be?
     
  2. ThermalFusion

    ThermalFusion

    Joined:
    May 1, 2011
    Posts:
    906
    Most likely something is entering the trigger immediately and then loads the next scene.Debug.Log the names of the objects causing the trigger enter.
     
    NomadKing likes this.
  3. Hapciupalit

    Hapciupalit

    Joined:
    Apr 24, 2015
    Posts:
    103
    my Player was entering the trigger from the next scene before everything was loading. I fixed it