Problem with LoadLevel

Hi all,

my game works perfect, but when the player dies, I call the Application.LoadLevel(Application.loadedlevel0;

and then the game stops work. my buttons is ok, but when I call a StartCoroutine, it dont enter on the method, dont execute animations or nothing what I want. I try to put all hierarchy inside a gameobject and insert a script in this game object with the DontDestroyOnLoad(transform.gameObject), but still dont work…

help pls!!

It would help if you pasted your code.

Not entirely sure but if that’s what you’re putting to load a level you might want to use: Application.LoadLevel(0);

im take off the dontdestroyonload.

when reload scene, the btnStart is ok, but when try enter on CountDown(), dont enter =/

its two classes

the Play() method is the method I call when click play again button

classe HudScript

        public MainScript mainScript;
    public GameObject startPanel;

    public void btnStart(){
        startPanel.SetActive(false);

        mainScript.StartGame ();
    }

    public void Play(){
        Application.LoadLevel(Application.loadedLevel);
    }

class MainScript

        public void StartGame(){
        StartCoroutine (CountDown ());
    }

    IEnumerator CountDown(){
        animTv.SetBool ("Count", true);
       
        yield return new WaitForSeconds (3);

        animTv.SetBool ("Count", false);
        tvCount.SetActive (false);
        tvWait.SetActive (true);
       
        StartCoroutine (ChangeCommand ());
    }

It looks like your scene is just looping? You should place the number of the Scene, example if you only have one scene in the Build Settings then use the code I posted above, but as far as I can tell you aren’t calling an OnGUI, Update or Start method anywhere? So none of that will show up, if you are getting an error without doing anything it could be that Application.LoadLevel call.

SOLVED! I forget my time.timescale = 0 when lose… on Strt I need to set timescale = 1

thx everbody

Guoicamarotto, just for future reference if you ever have a problem you should post all of the code. It’ll get solved a lot faster but glad you figured it out.

1 Like