Forum rules - please read before posting.

Change on how Custscene/Gameplay is handled between 1.75.6 and 1.75.4

Hello!
This is super difficult for me to explain it but I will try to do my best: I believe the way Cutscene/IsInGamePlay is handled may have changed. Let me explain what we had and how this new update brought a bit of a problem:

We have a script which is linked to a Global Variable. This scripts handles our inventory (wallet) which by default is always shown at the bottom except when there's a dialogue or pause menu. It automatically hides. When it's in gameplay it triggers a small animation which brings it from bottom to top and shows on the screen until a cutscene or dialogue pops up (there, the wallet disappears automatically until gameplay is resumed).

The variable named above, when is True, can make the wallet just "not" disappear on cutscenes, rather stay on top always visible. There were certain parts in the game in which action lists were triggered and they would "pause gameplay" (not run in background) and we would turn this variable "True" because we felt the wallet (inventory) should be there present and persitent. Basically the script detected that if it's true, please don't trigger any animation, just stay there until it's false. Then, at the end of the AL, we would turn this variable False and gameplay continues. This creates the feeling that the wallet never disappears, because it transitions from gameplay->cutscene->gameplay.

After updating to 1.76.5 we noticed that at the end of the AL, there is just this "frame" that makes the transition futile. I though it was the script but no, there was absolutely no way to make this transition between states seamless. It's like the AL always has one frame at the end that turns the states differently.
Yes, I tried the old project and absolutely works, but not anymore.

In the video uploaded I added the variable just on the "get on the stage". You can see that at the end it hides. In the past it never did.

https://www.veed.io/view/c6c3f115-2059-445e-9643-f27e54af989d?sharingWidget=true

Hope this helps or can point in the right direction to understand how it works.
As for the code (nothing had changed). Variable 15 is "always hide" and Variable 16 "always show". You can get the idea on what they do (and they do work!)

public void Update()
{
    if (AC.KickStarter.stateHandler.IsInGameplay())
    {
        if (AC.GlobalVariables.GetVariable(15).BooleanValue == false)
        {
            theAnimator.Play("Wallet Lombardi - First Animation");
            theIdlePen.GetComponent<RaiseTheParts>().canInteract = true;
        }
        else
        {
            theAnimator.Play("Wallet Lombardi - Idle Before First Animation");
            theIdlePen.GetComponent<RaiseTheParts>().canInteract = false;
        }
    }
    else
    {
        theIdlePen.GetComponent<RaiseTheParts>().canInteract = false;
    }

    if (AC.KickStarter.stateHandler.IsInCutscene() && AC.GlobalVariables.GetVariable(16).BooleanValue == false || AC.KickStarter.stateHandler.IsPaused() && AC.GlobalVariables.GetVariable(16).BooleanValue == false)
    {
        theAnimator.Play("Wallet Lombardi - Idle Before First Animation");
    }
}

Comments

  • The change in question is likely this one introduced in 1.75.5:

    • Fixed: Inconsistencies in the order in which Actions are updated inside Unity's game loop

    This was related to an issue in which Actions would be run at different times in Unity's game loop, depending on what Actions came before it.

    You might be able to get by renaming Update to LateUpdate, but rather than using a Variable to affect things I'd recommend using a naming convention / tag system on your ActionLists directly. For example, if you used a specific Tag for ActionLists you want the menu to react to in this way, you could hook into the OnBeginActionList custom event to determine this instead of setting/reading the value of a Variable.

  • Wow. I knew it was that line you pasted! We updated two version in a single update and read the whole thing to figure it out why this wasn't working anymore.

    Alright, well, this is what I tried: I sent the whole "update" part to this code and removed the variables lookup. Instead I compared the Tag of the Action List and if it is a certain string, then do this or that.

    private void OnEnable()
    {
        EventManager.OnBeginActionList += OnBeginActionList;
    }
    
    
    private void OnDisable()
    {
        EventManager.OnBeginActionList -= OnBeginActionList;
    }
    
    
    private void OnBeginActionList(ActionList actionList, ActionListAsset actionListAsset, int startingIndex, bool isSkipping)
    {
        if(actionList.CompareTag("Something"))
        {
    
        }
    }
    

    (the code is not complete, it's just how it should start. Am I correct? is that what you meant?)

    On another note: I'm wondering now if the Variables lookup like the code I did before is not "wise" or doesn't act anymore due to the new update, hence you recommended us to move to the custom Events. Are there differences "speedwise" or "spends less resources" than "Update()"?

    I guess when I have some more time and testing can check things further.
    Thanks a lot!

  • edited August 2022

    Yes, that was what I meant.

    I would have recommended this approach before the update. In general, it's more efficient to use events instead of checking every frame - that way, code is only run at the time you need it to.

    A single Update/LateUpdate function isn't really going to impact anything performance-wise, though.

  • Thanks. There's a thing that came into my mind and forgot to ask. By checking variables, I could do it halfway the AL and play with it in a single one. Now, by looking at Tags, there is no way I can play with it. Instead I'm thinking of chopping it in parts. Do you think there's a better way to do it halfway like I did it before the update? I mean, taking in considerations that variables won't be needed for this with custom events.
    Thanks a lot!

  • As I said, you should be good to use the same script but with LateUpdate if you want to use the old method.

  • Hello!! Sorry, I thought I already wrote it but no, it doesn't work that method. I found a workaround. After the AL finishes, I Run an Action List which is just the switching of the variable from True to False. This one runs in the backgroound but has a 0.1 delay. Not any other block than just the variable set. The rest, everything from the AL.
    This is a veeeery clumsy way to do it but it works.
    I'm not sure why but anyways, that's a fix. Thanks

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.