Forum rules - please read before posting.

Scene issues with AC 1.77.0

edited April 2023 in Technical Q&A

I've noticed two issues since I updated to AC 1.77.0.

The first is that in the OnStart cutscene for every scene, I include the following custom action to make sure the "skip subtitles" option is on, right before running an action to fade the scene in. Before the update, this worked perfectly. After the update, when loading the scene, the scene is displayed abruptly for a split of second, then it turns black, and only then does it fade in. If I skip this custom action, the scene loads as intended:

/*
 *
 *  Adventure Creator
 *  by Chris Burton, 2013-2016
 *  
 *  "ActionTemplate.cs"
 * 
 *  This is a blank action template.
 * 
 */

using UnityEngine;
using System.Collections;

#if UNITY_EDITOR
using UnityEditor;
#endif

namespace AC
{

    [System.Serializable]
    public class ActionSubtitlesSkippable : Action
    {

        // Declare variables here
        public bool SkippableSubtitles;

        public ActionSubtitlesSkippable ()
        {
            this.isDisplayed = true;
            category = ActionCategory.Dialogue;
            title = "Toggle Skip Subtitles";
            description = "Allows you to toggle whether subtitles are skippable.";
        }


        override public float Run ()
        {
            /* 
             * This function is called when the action is performed.
             * 
             * The float to return is the time that the game
             * should wait before moving on to the next action.
             * Return 0f to make the action instantenous.
             * 
             * For actions that take longer than one frame,
             * you can return "defaultPauseTime" to make the game
             * re-run this function a short time later. You can
             * use the isRunning boolean to check if the action is
             * being run for the first time, eg: 
             */
            if (SkippableSubtitles)
            {
                // AdvGame.GetReferences ().speechManager.allowSpeechSkipping = true;

                AC.KickStarter.speechManager.allowSpeechSkipping = true;
            }
            else
            {
                // AdvGame.GetReferences ().speechManager.allowSpeechSkipping = false;

                AC.KickStarter.speechManager.allowSpeechSkipping = false;
            }


            if (!isRunning)
            {
                isRunning = true;
                return defaultPauseTime;
            }
            else
            {
                isRunning = false;
                return 0f;
            }
        }


        #if UNITY_EDITOR

        override public void ShowGUI ()
        {
            // Action-specific Inspector GUI code here

            SkippableSubtitles = EditorGUILayout.Toggle ("Check to skip:", SkippableSubtitles);

            AfterRunningOption ();
        }


        public override string SetLabel ()
        {
            // Return a string used to describe the specific action's job.

            string labelAdd = "";
            return labelAdd;
        }

        #endif

    }

}

No other action that I can identify causes this problem, only this one. Any idea why this could be happening?

The second error happens with the Dialogue System integration provided by Tony from Pixel Crushers, more specifically with the Remember Dialogue System component. This component is on the Dialogue Manager prefab, which is added as a gameobject to every scene, with a manual Constant ID retained in the prefab.

Before the AC update, it worked well. After the update, loading the scene for the first time works just fine. If you change scenes, it still works. But when you switch back to the original scene, it breaks the game. I get the following error in the console:

MissingReferenceException: The object of type 'RememberDialogueSystem' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
AC.LevelStorage+<UnloadScriptData>d__29.MoveNext () (at Assets/AdventureCreator/Scripts/Save system/LevelStorage.cs:751)
AC.LevelStorage+<LoadSceneData>d__19.MoveNext () (at Assets/AdventureCreator/Scripts/Save system/LevelStorage.cs:437)
AC.LevelStorage+<ReturnCurrentLevelData>d__7.MoveNext () (at Assets/AdventureCreator/Scripts/Save system/LevelStorage.cs:165)
AC.SaveSystem+<InitAfterLoadCo>d__47.MoveNext () (at Assets/AdventureCreator/Scripts/Save system/SaveSystem.cs:755)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <ad50157ee00e45cdb3c8bd67012f8804>:0)

By breaking, I mean the OnStart actionlist doesn't run, and the player is not teleported to the correct Player Start marker (I use a Scene Graph to connect scenes).

I know the integration was provided by Tony, but do you know what changed that could be breaking this so I can report it to him? Or was this change unintended and can be fixed on the AC side of things?

Sorry for all the requests lately!

Comments

  • Sorry for all the requests lately!

    Please don't be - all bugfix reports are appreciated.

    After the update, when loading the scene, the scene is displayed abruptly for a split of second, then it turns black, and only then does it fade in

    What version were you previously using?

    The Action is set up to "consume" a frame before ending. I'm not sure why it was previously different, but strip down your Run function to the following:

    override public float Run ()
    {
        AC.KickStarter.speechManager.allowSpeechSkipping = SkippableSubtitles;
        return 0f;
    }
    

    The second error happens with the Dialogue System integration provided by Tony from Pixel Crushers, more specifically with the Remember Dialogue System component.

    If you temporarily replace the component with an AC one (e.g. Remember Visibility), does the error still show?

  • What version were you previously using?

    1.76.4

    The Action is set up to "consume" a frame before ending. I'm not sure why it was previously different, but strip down your Run function to the following:

    This worked! Thanks. I was chaining this with another custom action that was also set to consume a frame before ending. It seems that a single action that consumes a frame before ending doesn't currently cause problems, but two of them in a row do.

    If you temporarily replace the component with an AC one (e.g. Remember Visibility), does the error still show?

    It does.

    This is how the Dialogue Manager works:

    The Dialogue Manager's default settings make it persist across scene changes and ensure that only one copy exists in the scene. You will typically use one Dialogue Manager, added to your main menu scene. You can put other Dialogue Managers in your location scenes so you can test them without having to come in from the main scene. But keep in mind that in normal gameplay the Dialogue Manager from the main scene will carry through and destroy the "test" Dialogue Manager in your location scene.

    So Dialogue System makes the first scene's manager persistent, but when you leave and return to that scene, the manager will naturally be there in the hierarchy again. DS takes care of this by destroying the non-persistent copy that 'respawns' whenever you reenter the scene. What might be happening here is that after the AC update, DS is destroying the non-persistent copy before AC has the chance to load its Remember component? Maybe? But again, this didn't happen before the update.

  • It does sounds like it's the case.

    You could try creating a new first scene, which is never visited again, and moving the DM to there.

  • edited April 2023

    Hm, that would work for a build, but would be a nightmare for making the game. I'll take it to the DS forums and see what Tony suggests.

    While I wait for him, question: I see the console error says "Your script should either check if it is null or you should not destroy the object", and this refers to the AC scripts that are attempting to load the destroyed component. If the change that broke this is necessary for the workings of AC, instead of rolling it back, how feasible is it to introduce null checks so that AC doesn't attempt to access the object that has been destroyed?

  • I snuck in a null-reference check into v1.77.1 - give it a try now. You'll still have an issue with the data not being loaded, but it may at least allow the game to continue.

  • Sorry for the delay checking this out. I spoke to Tony, and before you had included the null-reference checks, he said that if I added the remember component to AC's Persistent Engine prefab instead of the DS Dialogue Manager in the scene, it would work.

    After you added the null-reference checks, everything seems to work fine even without moving the remember component to the persistent engine.

  • edited April 2023

    This isn't a bug report or request for help, just an observation: it does seem that AC 1.77.0 introduced changes in the order that things happen that I haven't fully understood yet. The actions we fixed earlier in this thread were an example of this. The bug with the Dialogue System integration's Remember component is another example. And today I came across an entire section of my game that was broken by the update:

    My NPCs all have a schedule, and I wrote a script that makes heavy use of AC paths to place the NPCs exactly where they need to be on start/load. Basically, I give a path a start time, and the script automatically calculates how long it takes for the NPC to walk it. Then it checks the time the scene was entered, and if that happens to be between the start time of the path and the predicted time at destination, it moves the path nodes to the correct positions with its start() function. This way, I only need to use one action in the OnStart cutscene to teleport the NPC to the start of the path and tell them to follow it.

    The 1.77.0 update completely broke this. The OnStart cutscene now runs before my custom script's start() function. I had to rename it to awake(), and now it works again. But I'd advise caution if anyone has lots of scripts and actionlists running at the same time, because they might no longer be running in the order they used to.

  • Thanks for the advice.

    In the GameEngine's Multi Scene Checker component, you can set its Call Startup Process Inspector field to First Frame Update - this should prevent anything from being called from the Start function.

    If you're looking to inject code within AC's startup operation, it's also worth doing so via event hooks: OnInitialiseScene will be run once AC has initialised, but before the "start" processes have run, while OnAfterChangeScene will be run once the latter have run as well.

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.