Forum rules - please read before posting.

GameState Pause <> Cutscene infinite loop

Hi there,

This is gonna be hard to explain...

I have two PlayMaker FSMs that continually monitor AC GameState for changes.

The first one goes like this...:

image

Those actions in green are Interact() methods pointing to 'run in background' Interaction action lists.

Then there's also this one, that checks for GameState.Pause changing...:

image

That green action also calls for an Interaction that runs in the background. And those 'pause' actions relate to Dialogue System, not AC.

Now, my issue is that if either one of these FSMs is activated AND during a cutscene I press the Menu button to go to the Pause Menu, the game pauses alright, but immediately after it goes into Cutscene mode and then Pause, and then Cutscene, etc., which is a problem because you lose the ability to effectively click 50% of the time.

If no cutscene is running, GameState remains in Pause mode.

I thought at first that one of these FSMs would be responsible for changing GameState value, so I disabled one and then the other in another try, but they BOTH need to be disabled for this not happening. And the only common thing they have is that both of them call an Interact() on running in background Interactions (no cutscene components).

So my reading of this is that if a cutscene is playing when you go to Pause, and then any interaction is run, regardless of its 'run in background' flag, "something" must update the GameState value to Cutscene and then back to Pause, which in my code triggers another Interaction and an infinite loop ensues.

In fact, and to be completely sure that the problem is generated by this condition only, I've disabled these two FSMs and created another one that the only thing it does is watching for a GameState.Cutscene = true condition change (going from true to false and vice-versa) to run, and then calls an "empty" (just a comment action) run in background interaction. This...:

image

image

And guess what? It does the same. Infinite pause/cutscene loop.

Weird thing though is that the comment doesn't infinitely prints on the console, as it should...

Has this makes any sense to you? 8-}

I'm going to keep trying modifying my code to try to avoid this loop from happening, but I'm more or less at a loss at why it is occurring in the first place. I mean, this shouldn't happen, right? Those interactions are flagged to run in the background and shouldn't trigger a Cutscene GameState...

I can provide you a video of my testing or any other reference if you want.

Oh, and the point of this working is that I want to allow players to Quit the game even inside a cutscene. I forgot to mention my motivation behind this.

Thank you for your time!

Comments

  • Why is all this necessary to allow players to quit?  The "Quit" button in the default Pause menu will show regardless of any cutscenes - only the "Save" button will be hidden.

    Normally, AC only goes into Pause mode when a pausing Menu is turned on.  If you unchecked Pause game when enabled? in any Menu that gets turned on as part of this, does it then behave?

    If you must check AC's GameState, it's better practice to rely on the OnEnterGameState / OnExitGameState custom events, so that you can run code/ActionLists only when the state is explicitly changed, as opposed to having to check it every frame.

    More on custom events can be found in the Manual, but to run code whenever e.g. a new state is entered:

    private void OnEnable ()
    {
        EventManager.OnEnterGameState += EnterGameState;
    }

    private void OnDisable ()
    {
        EventManager.OnEnterGameState -= EnterGameState;
    }

    private void EnterGameState (GameState _gameState)
    {
        Debug.Log ("Entered: " + _gameState);
    }

  • I think I didn't explain my problem good enough.  :P

    My issue is not the Quit button not showing up. It is there when I bring up the Pause menu with Esc.

    I'll attach a video in here so you can see the real nature of the problem, but the last time I tried to link a full video link, the forum told me a moderator should approve it, so I'll play safe and split the web address so it doesn't get recognized, okay?

    Here...:

    https: //youtu.be/ sSUKZNZTxwA

    Anyway, I've followed your suggestion at not using any 'next frame' gets. Your code is a better approach performance-wise as well. The only thing, as I use PlayMaker, I've modified the thing as follows...:


    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using HutongGames.PlayMaker;
    using AC;

    public class GameStateChange : MonoBehaviour {

    private void OnEnable ()
    {
    EventManager.OnEnterGameState += EnterGameState;
    }

    private void OnDisable ()
    {
    EventManager.OnEnterGameState -= EnterGameState;
    }

    private void EnterGameState (GameState _gameState)
    {
    Debug.Log ("Entered: " + _gameState);
    FsmString state = FsmVariables.GlobalVariables.FindFsmString ("ACGameState");
    state.Value = _gameState.ToString ();
    }

    }

    That stores the GameState value, converted to String, in a PlayMaker global string variable so it can be 'watched' for changes in an FSM.

    And again, for testing purposes, I've used a very simple one:

    image

    It's the same FSM that makes a call to a placeholder interaction:

    image

    Well, it's all the same as before with the only change that now it only triggers after the GameStateChange triggers and the global variable is also changed.

    So my theory of that interaction (any interaction actually) reverting the GameState to 'Cutscene' still holds true.

    That's my question: Is a 'run in background' flagged interaction supposed to change the GameState at all?
  • In which version of AC is this all being done?

    Generally no - though is this ActionList in the scene or an asset file?  As there's still an update in between the AC event and the PM FSM though, that could be causing issues.

    I'm still not clear on what the core issue is, though.  Is it that the UI has a bit gap in between Options and Quit?  That can be fixed by introducing layout components to your Unity UI, and having AC disable the Save/Load button gameobjects, as opposed to just hiding them.
  • edited December 2017
    It's Unity 5.5.3f1 and AC 1.60.4, and the action list is on the scene. I'll try with an asset-based one, just in case.

    Also, it's not a cosmetic issue what I'm trying to overcome here, I guess I've lingered too much in the pause menu in my video. It's okay that 'save' and 'load' are leaving a gap there.

    My main problem here is that the GameState really goes to Cutscene and switches back to Paused in a very quick succession (I've got dozens of Debug.Log message stating that fact), so when the cursor is an hourglass due to entering Cutscene state I lose the ability to click on any menu option.

    Also, I don't know if you heard that in the video, but the background SFX sounds stop and continue very quickly as well, which also match a 'Paused' <> 'Cutscene rapid switch behavior.

    Those two things are cosmetic issues, to be honest, but the fact that it is happening at all bothers me because Murphy's Law says I will have other problems with it in the future, non-cosmetic that time, I'm sure.

    Anyway, I'm going to try a couple of things, being one set up a new barebones scene and tell you my findings.

    Thanks!
  • Sorry, the version of AC is 1.60.5
  • edited December 2017
    Hi again,

    "Good" news. I've been able to replicate the issue with a barebones project. :P  I've installed just AC 1.60.5 and PlayMaker 1.8.5 for this.

    What I've done is...:
    • Create a hotspot called testHotspot in the scene
    • Add a cube for visibility
    • Add a Use interaction called testHotspot: Use with 'Pause Gameplay' set
    • Edit the Use interaction like this:
    image
    ...so it's an infinite CutScene for testing purposes.
    • Create the script you suggested to log GameState changes in the console, with my additional two lines for converting the Enum value to a string in a PlayMaker global variable called ACGameState.
    • Create a 'watcher' PlayMaker FSM like this...:
    image
    image
    What this does is to run the second 'placeholder interaction' action when the PlayMaker global variable ACGameState changes its value as a result of AC GameState changing in the background. Then it returns to the first 'Watcher' action to continue its monitoring.
    • Add that placeholder Interaction in the scene, with 'Run In Background' selected, and just one 'rename label' action to make sure it doesn't do anything that pauses the game...:
    image

    Then the testing begins. I'll link another video, but with the console visible this time...:

    https: //youtu.be /4OM-M0dvr6w

    This should be self-explanatory, I think. As you see, GameState doesn't change to Cutscene, unless there was a cutscene playing already when it goes to Paused state in the menu, AND also another interaction is called after going to Paused.

    It's like if it doesn't support to actually run in the background a 'run in background' interaction when a cutscene is waiting to be resumed (?).

    If you want my testing project, please tell me. And thank you for following up this.
  • Thanks for the details, issue recreated.

    Can't say what's to blame at this stage, but now that I've got it on my end I'll look into it and let you know.
  • Okay then.

    I have additional info that I think it may be related.

    Another plugin I have is Dialogue System and it has a script component called 'Adventure Creator Bridge'. Among other things, it has a feature to switch AC GameState value to 'Dialog Options' when you start a Dialogue System conversation.

    What you get with this is that the mouse cursor doesn't lock itself with the hourglass icon when you start a conversation from an AC Cutscene, which is aesthetically nicer.

    I've set that option to 'Always'. In fact, take a look at all settings in this cap...:

    image

    The issue I've observed is that I have a similar behavior to the one we've been discussing when I'm in a conversation. But instead of having a very quick Paused <> Cutscene loop, what I have now is a Dialog Options <> Cutscene loop.

    I didn't realize this before because the cursor doesn't get to be seen with the hourglass icon. I suppose Dialogue System "wins" against AC in this instance, so the, err... "cursor system" (?) doesn't have time to switch to the hourglass icon, but the constant GameState switching is noticeable now that I have your Debug.Log console messages.

    Just my additional two cents.
  • If the "hourglass icon" is flickering on because the ActionList is beginning a Conversation, try setting it to Run In Background to prevent it entering Cutscene mode before DialogOptions.

    Without the added complexity of bringing Dialogue System into play, I've fixed the original issue for the next release.
  • Great!

    And no, I don't have even a cosmetic issue with this. I've only brought it to attention just in case it could have something in common with the main problem. ;)

    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.