Search Unity

Scene mechanics doesn't work after loading scene 2'nd time

Discussion in 'Scripting' started by Artifacta, Mar 30, 2011.

  1. Artifacta

    Artifacta

    Joined:
    Mar 14, 2011
    Posts:
    22
    I have a game with a mainMenu, where there is some objects spinning and moving etc. Everything works fine when I load the menu screen as the first scene, for example when I start the game and it shows that scene as the first one. If I enter a level and go back to my main menu nothing is moving, it's like physics are frozen, gravity etc doesn't work, I'm loading my scene like this:

    Code (csharp):
    1.         if (quitButton == true)
    2.         {
    3.             if (Application.CanStreamedLevelBeLoaded("MainMenu"))
    4.             {  
    5.                 Destroy(GameObject.FindWithTag("MusicBox"));
    6.                 Application.LoadLevel("MainMenu");
    7.             }  
    8.         }
    I have also tried without that CanStreamLevelBeLoaded, but didn't make a difference. I have no clue why it's doing this, since I'm loading all my scenes like this and all my levels physics works just fine.
     
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    Difficult to say without more information but are you using DontDestroyOnLoad with objects in the first scene to make them persist? If so then when you return to that scene, new instances will be created. These could interfere with what is going on in the scene.

    If this doesn't sound plausible then can you give any more information about what is going on in the menu scene?
     
  3. Artifacta

    Artifacta

    Joined:
    Mar 14, 2011
    Posts:
    22
    I figured it out :) just a very stupid error. Time.timescale was at 0 that's why :)
     
  4. bigmisterb

    bigmisterb

    Joined:
    Nov 6, 2010
    Posts:
    4,221
    I would have blamed that one on the dog.
     
  5. csomakk

    csomakk

    Joined:
    Apr 15, 2014
    Posts:
    1
    ahhh, it was the timescale for me as well :DDD