Forum rules - please read before posting.

Loads wrong scene

2

Comments

  • Unfortunately updating adventure creator is not an option. I've tried a few times but it overwrites too much of our game (for example, i tried just now and it overwrote our music storage - i think we've accidentally just left too many loose ends we didn't realize would be a problem and our release date is too soon for me to hunt it down.) I think I'm just going to skip this and save it for a DLC :)

  • Unfortunately updating adventure creator is not an option.

    I'm just asking the version you're using - there may be a tweak you can make to your version rather than updating it completely.

    i tried just now and it overwrote our music storage

    Did you re-assign your own game's Managers afterwards, or do you rely on the Demo game's Managers?

  • OK! Could you tell me how to tell what version is installed? I have 1.77.4 downloaded, since I did try to upgrade and reverted, but I'm not confident that's the version installed anymore.

    All of our Managers in AC Game Editor are uniquely named. There isn't one for music, just speech.

  • I have a more pressing issue though... For some reason suddenly the game is behaving as though I am loading a save, but I am lot, I'm just loading a scene.

    I have this object, L2_Passengers in the street scene, which is disabled in all scenes except L2.

    When I play through L1 and get to L1 street, L2_Passengers is enabled, but then it's immediately disabled by the save system.

    This is the log it's throwing on Disable:

    L2_Passengers I am disabled UnityEngine.StackTraceUtility:ExtractStackTrace () (at C:/buildslave/unity/build/Runtime/Export/Scripting/StackTrace.cs:37) UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[]) UnityEngine.Logger:Log (UnityEngine.LogType,object) UnityEngine.Debug:LogError (object) PingOnActivate:OnDisable () (at C:/Users/gillian/_Client/SSE/Unity/PeoPoli/Assets/PingOnActivate.cs:21) RememberMultipleEnabled:LoadData (string) (at C:/Users/gillian/_Client/SSE/Unity/PeoPoli/Assets/Scripts/ExtendPlugins/RememberMultipleEnabled.cs:32) AC.LevelStorage:UnloadScriptData (System.Collections.Generic.List1<AC.ScriptData>,UnityEngine.SceneManagement.Scene) (at C:/Users/gillian/_Client/SSE/Unity/PeoPoli/Assets/AdventureCreator/Scripts/Save system/LevelStorage.cs:750) AC.LevelStorage:LoadSceneData (AC.SingleLevelData,AC.SubScene) (at C:/Users/gillian/_Client/SSE/Unity/PeoPoli/Assets/AdventureCreator/Scripts/Save system/LevelStorage.cs:411) AC.LevelStorage:ReturnCurrentLevelData () (at C:/Users/gillian/_Client/SSE/Unity/PeoPoli/Assets/AdventureCreator/Scripts/Save system/LevelStorage.cs:167) AC.SaveSystem:InitAfterLoad () (at C:/Users/gillian/_Client/SSE/Unity/PeoPoli/Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:691) AC.MultiSceneChecker:Start () (at C:/Users/gillian/_Client/SSE/Unity/PeoPoli/Assets/AdventureCreator/Scripts/Game engine/MultiSceneChecker.cs:62)

    And RememberMultipleEnabled, which should only be called when I load a save but seems to be running whenever a scene is loaded:

    `
    using UnityEngine;
    using AC;

    public class RememberMultipleEnabled : Remember
    {

    public GameObject[] objectsToSave;
    
    public override string SaveData()
    {
        EnabledMultipleData data = new EnabledMultipleData();
        data.objectID = constantID;
        data.savePrevented = savePrevented;
    
        data.isEnabled = new bool[objectsToSave.Length];
        for (int i = 0; i < objectsToSave.Length; i++)
        {
            data.isEnabled[i] = objectsToSave[i].activeSelf;
        }
    
        return Serializer.SaveScriptData<EnabledMultipleData>(data);
    }
    
    public override void LoadData(string stringData)
    {
        EnabledMultipleData data = Serializer.LoadScriptData<EnabledMultipleData>(stringData);
        if (data == null) return;
        SavePrevented = data.savePrevented; if (savePrevented) return;
    
        for (int i = 0; i < data.isEnabled.Length; i++)
        {
            objectsToSave[i].SetActive(data.isEnabled[i]);
        }
    }
    

    }

    [System.Serializable]
    public class EnabledMultipleData : RememberData
    {

    public bool[] isEnabled;
    
    public EnabledMultipleData() { }
    

    }
    `

    This only happens in the build. It was working fine until this week.

  • Could you tell me how to tell what version is installed? I have 1.77.4 downloaded, since I did try to upgrade and reverted, but I'm not confident that's the version installed anymore.

    It's listed at the bottom of each Manager, as well as in AC's "About" window available in the top toolbar.

    All of our Managers in AC Game Editor are uniquely named. There isn't one for music, just speech.

    Though they are set within their own Editor window, music track data is stored within the Settings Manager. So long as you're using your own Managers to build your game (as opposed to those of the Demo game), then you can restore them after updating. See the Manual's "Updating Adventure Creator" chapter for details on this.

    RememberMultipleEnabled, which should only be called when I load a save but seems to be running whenever a scene is loaded

    Remember script data are not merely applied when loading a save file - but also when a scene is switched to.

    If you leave a scene after making a change to it, the appropriate Remember component will see that this change is applied upon re-entering it - even if save-game files are not involved. That's the correct intent behind the Remember component system.

  • My version is 1.74.2

    The remember scripts are working as they used to. Do you have any advice about the GVar issue?

    NullReferenceException: Object reference not set to an instance of an object
    AC.GVar.set_FloatValue (System.Single value) (at Assets/AdventureCreator/Scripts/Variables/GVar.cs:766)
    AC.GlobalVariables.SetFloatValue (System.Int32 _id, System.Single _value, System.Boolean synchronise) (at Assets/AdventureCreator/Scripts/Static/GlobalVariables.cs:327)
    TimePlayedCalculator.Update () (at Assets/TimePlayedCalculator.cs:43)

    TimePlayerCalculator line 43 is just
    AC.GlobalVariables.SetFloatValue(35, startTime);

  • To fix this manually, without updating, open up AC's GVar script and replace line 766:

    KickStarter.eventManager.Call_OnVariableChange (this);
    

    with:

    if (KickStarter.eventManager) KickStarter.eventManager.Call_OnVariableChange (this);
    
  • This worked, no more error! The fade out doesn't last though - the menu comes back up before it switches scenes. Here's how I have it set up

  • Check the Camera: Fade Action's Wait until finish? Actino to complete the fade transition before running the next Action.

  • No change unfortunately.

  • RememberMultipleEnabled, which should only be called when I load a save but seems to be running whenever a scene is loaded

    Remember script data are not merely applied when loading a save file - but also when a scene is switched to.

    If you leave a scene after making a change to it, the appropriate Remember component will see that this change is applied upon re-entering it - even if save-game files are not involved. That's the correct intent behind the Remember component system.

    If this is the case, how do I go about ONLY accessing the saved state of an object when manually loading a save file and not when loading a scene? Our players enter the same scenes dozens of times in many different states throughout the game. They should have different states at different times.

    I tried just nuking the remember system and just checking what should be enabled in the Start funtion, but it looks like when you load a scene, Start runs before AC switches the variables, so it loads the wrong objects.

  • No change unfortunately.

    What menu turning on prematurely are you referring to? I'm not clear on the behaviour you're getting.

    how do I go about ONLY accessing the saved state of an object when manually loading a save file and not when loading a scene?

    If you want AC to "forget" data related to a scene (which is loaded upon re-entering it), then you can do so with the ClearLevelData function:

    AC.KickStarter.levelStorage.ClearLevelData ("MyScene");
    
  • (So sorry I ended up with a single forum post discussing like three different issues, it's probably confusing, we're so close to releasing and I really appreciate your help and patience!)

    Writing up the sequence of events showed me that during the scene change, the Load menu was blinking on while the Loading Scene was present. I've unchecked 'use Loading Screen' in the settings and that fixed it!

    Thank you, I will try Clear level data! I have some idea of using a variable in an Awake function to check if the scene has been loaded from the save menu vs loaded from an in-scene actionlist, but I can image this may get complicated as that variable is overwritten by the value from the save file. Is there an internal variable that may already exist to track this?

  • If you want to clear scene data, you'd need to do it before it opens.

    You should be able to do this by hooking into the OnBeforeChangeScene custom event, and reading the state of the SaveSystem's loadingGame property.

    Something like:

    void OnEnable () { EventManager.OnBeforeChangeScene += OnBeforeChangeScene; }
    void OnDisable () { EventManager.OnBeforeChangeScene -= OnBeforeChangeScene; }
    
    void OnBeforeChangeScene (string nextSceneName)
    {
        if (KickStarter.saveSystem.loadingGame == LoadingGame.No)
        {
            KickStarter.levelStorage.ClearLevelData (nextSceneName);
        }
    }
    
  • edited July 2023

    I managed to reproduce this bug "Is mostly seems to be an issue with the street scene - sometimes a save that should be Hub_Street will load Hub_Office instead, and will consistantly load Hub_Office instead."

    It's only happening in the build - everything seems to work fine in the editor.

    Steps to reproduce:

    • Play through week 1. Saves made in week one seem to be fine.
    • In week 2, go to the street, save.
    • Get on the bus, save
    • Play go into the building and up the elevator, save
    • Load the bus or street save.
      Result: Loaded the wrong scene. On earlier tests it loaded Hub_Office, seemingly a non-existant camera. This time it is loading an empty scene called StopGap. This only happens in the build, it works fine in the editor. It only seems to effect saves made in Hub-Street. Once a save is "corrupted", it stays corrupted in the same way.

    You can skip the minigame with the meter in the right corner with Alt-shift-a .
    You can confirm which scene is loaded by bringing up the debug panel with ctrl-x.
    (Working on pming you a copy of our project - it's a behemoth and I'm trying to figure out how to cut it down while still reproducing the issue.)

  • It might be possible to get some further clues beforehand.

    What custom scripts does your game make use of, and is AC always relied on for scene-switching?

    If so, all scene-switch commands will go through AC's SceneChanger script. If you open that up, look for the two ChangeScene functions (one for referencing by build index, another by filename). Try placing Debug.Log statements at the tops of these, to get feedback about what and when these functions are called.

    At runtime, these logs will appear in your Log file - but you can also access them from an in-game Console asset such as this one.

    What are the logs - stacktraces included - that show at the time the issue occurs, and how do they differ from the expected?

  • We use a different system for switching scenes in actionlists, but this bug only happens when loading a save file from the menu, which would be all AC. I'll take a look as soon as I get home.

  • edited July 2023

    Here is what it says - it should be loading Hub_Street

    Loading the scene by name StopGap UnityEngine.StackTraceUtility:ExtractStackTrace () (at C:/buildslave/unity/build/Runtime/Export/Scripting/StackTrace.cs:37) UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[]) UnityEngine.Logger:Log (UnityEngine.LogType,object) UnityEngine.Debug:LogWarning (object) AC.SceneChanger:ChangeScene (string,bool,bool,bool) (at C:/Users/gillian/_Client/SSE/Unity/PeoPoli/Assets/AdventureCreator/Scripts/Game engine/SceneChanger.cs:306) AC.SaveSystem:ReceiveDataToLoad (AC.SaveFile,string) (at C:/Users/gillian/_Client/SSE/Unity/PeoPoli/Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:530) AC.SaveSystem:LoadSaveGame (AC.SaveFile) (at C:/Users/gillian/_Client/SSE/Unity/PeoPoli/Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:409) AC.SaveSystem:LoadGame (int,int,bool) (at C:/Users/gillian/_Client/SSE/Unity/PeoPoli/Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:325) AC.MenuSavesList:ProcessClick (AC.Menu,int,AC.MouseState) (at C:/Users/gillian/_Client/SSE/Unity/PeoPoli/Assets/AdventureCreator/Scripts/Menu/Menu classes/MenuSavesList.cs:790) AC.MenuElement:ProcessClickUI (AC.Menu,int,AC.MouseState) (at C:/Users/gillian/_Client/SSE/Unity/PeoPoli/Assets/AdventureCreator/Scripts/Menu/Menu classes/MenuElement.cs:259) AC.MenuSavesList/<>c__DisplayClass31_1:<LoadUnityUI>b__0 () (at C:/Users/gillian/_Client/SSE/Unity/PeoPoli/Assets/AdventureCreator/Scripts/Menu/Menu classes/MenuSavesList.cs:198) UnityEngine.Events.InvokableCall:Invoke () (at C:/buildslave/unity/build/Runtime/Export/UnityEvent/UnityEvent.cs:180) UnityEngine.Events.UnityEvent:Invoke () (at C:/buildslave/unity/build/Runtime/Export/UnityEvent/UnityEvent/UnityEvent_0.cs:58) UnityEngine.UI.Button:Press () (at C:/Users/gillian/_Client/SSE/Unity/PeoPoli/Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Button.cs:68) UnityEngine.UI.Button:OnPointerClick (UnityEngine.EventSystems.PointerEventData) (at C:/Users/gillian/_Client/SSE/Unity/PeoPoli/Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Button.cs:110) UnityEngine.EventSystems.ExecuteEvents:Execute (UnityEngine.EventSystems.IPointerClickHandler,UnityEngine.EventSystems.BaseEventData) (at C:/Users/gillian/_Client/SSE/Unity/PeoPoli/Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:50) UnityEngine.EventSystems.ExecuteEvents:Execute<UnityEngine.EventSystems.IPointerClickHandler> (UnityEngine.GameObject,UnityEngine.EventSystems.BaseEventData,UnityEngine.EventSystems.ExecuteEvents/EventFunction1<UnityEngine.EventSystems.IPointerClickHandler>) (at C:/Users/gillian/_Client/SSE/Unity/PeoPoli/Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:262)
    UnityEngine.EventSystems.StandaloneInputModule:ReleaseMouse (UnityEngine.EventSystems.PointerEventData,UnityEngine.GameObject) (at C:/Users/gillian/_Client/SSE/Unity/PeoPoli/Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/InputModules/StandaloneInputModule.cs:187)
    UnityEngine.EventSystems.StandaloneInputModule:ProcessMousePress (UnityEngine.EventSystems.PointerInputModule/MouseButtonEventData) (at C:/Users/gillian/_Client/SSE/Unity/PeoPoli/Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/InputModules/StandaloneInputModule.cs:642)
    UnityEngine.EventSystems.StandaloneInputModule:ProcessMouseEvent (int) (at C:/Users/gillian/_Client/SSE/Unity/PeoPoli/Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/InputModules/StandaloneInputModule.cs:548)
    UnityEngine.EventSystems.StandaloneInputModule:ProcessMouseEvent () (at C:/Users/gillian/_Client/SSE/Unity/PeoPoli/Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/InputModules/StandaloneInputModule.cs:528)
    UnityEngine.EventSystems.StandaloneInputModule:Process () (at C:/Users/gillian/_Client/SSE/Unity/PeoPoli/Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/InputModules/StandaloneInputModule.cs:282)
    UnityEngine.EventSystems.EventSystem:Update () (at C:/Users/gillian/_Client/SSE/Unity/PeoPoli/Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:385)

    (Filename: C:/Users/gillian/_Client/SSE/Unity/PeoPoli/Assets/AdventureCreator/Scripts/Game engine/SceneChanger.cs Line: 306)`

  • We use a different system for switching scenes in actionlists

    Could you elaborate on this? It may affect the save data.

    Also, are you relying on Player-switching?

    The error suggests that it's a case of the save data itself being wrong - the loading operation looks normal. For the given save you're loading, it looks like it's recorded the scene name to be StopGap rather than HubStreet.

    You can use the Save-game File Manager (at the top of the Settings Manager) to view the contents of your save file. If your build and Editor save directories are different, locate the runtime file and copy it into the Editor save folder so that it can be picked up by the Manager.

  • We're not getting the issue in action lists, only loading saves, which are using the script you mentioned. We're using Michsky's Loading Screen to switch scenes. We're using it for all scenes, but this bug is only applying to the street scene. Here is that function:

    public static void LoadScene(string targetScene)
    {
    try
    {
    instance = Instantiate(Resources.Load<GameObject>("Loading Screens/" + presetName).GetComponent<LSS_LoadingScreen>());
    instance.gameObject.SetActive(true);
    DontDestroyOnLoad(instance.gameObject);

    if (instance.setTimeScale) { Time.timeScale = 1; }
    if (instance.customSceneActivation) { instance.enablePressAnyKey = false; instance.waitForPlayerInput = false; }

    instance.processLoading = true;
    instance.loadingProcess = SceneManager.LoadSceneAsync(targetScene);
    instance.loadingProcess.allowSceneActivation = false;
    instance.onLoadingStart.Invoke();
    }

    catch
    {
    Debug.LogError("<b><color=orange>[LSS]</color></b> Cannot initalize the loading screen because either <b><color=orange>'" +
    targetScene + "'</color></b> scene has not been added to the build window, or <b><color=orange>'" + presetName
    + "'</color></b> prefab cannot be found in <b>Resources/Loading Screens</b>.");
    instance.processLoading = false;

    if (instance != null)
    {
    Destroy(instance.gameObject);
    }
    }
    }



    I added this at line 434 of LevelStorage.SaveSceneData:


    Scene sceneMangerScene = UnityEngine.SceneManagement.SceneManager.GetActiveScene();

    Debug.LogError("LevelStorage Scenechanger: " + SceneChanger.CurrentSceneName + " sceneMangerScene: " + sceneMangerScene.name);

    It prints Hub_street for both variables, but Player data #0 Scene info Current is StopGap.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.