Forum rules - please read before posting.

[SOLVED] Pause menu doesn't pause if triggered from an actionlist

edited October 2014 in Technical Q&A
Hey Chris,

I've been retooling my menus a little bit, and instead of having two variants of each submenu like you describe in the tutorial - one for the Main Menu and one for the Pause menu - I decided to use Actionlists to check whether the game is in scene 0 (the main menu) or not, and deciding that way which menu to return to when pressing the Back button.

This works great in theory, but what I've found is that, during gameplay, if I go into the Pause menu, then go into one of the submenus like Options or Controls, then click Back to go into the Pause menu again, the game unpauses! (I am running an in-scene actionlist at the same time)

There's a warning that the Actionlist can't continue because the Pause menu was turned on. But the whole actionlist is supposed to stop when the Pause menu turns on anyway, that's the last action in the actionlist, and it's set to Stop. It's not even fading.

So then I tried to do it via script, but it turns out the same way. Here's the script I used in MenuSystem.cs:

if (_menu.title == "Controls") {
if (_element.title == "Back") {
_menu.TurnOff(true);
if (Application.loadedLevel == 0) {
PlayerMenus.GetMenuWithName("Main Menu").TurnOn(true);
}
else {
state.GameState = GameState.Paused;
PlayerMenus.GetMenuWithName("Pause").TurnOn(true);
}
}
}

Is this a bug, or any way to work around it?

Comments

  • I found the same issue myself when building my own game.  It's only when I get to work on it that I find such quirks!  Expect it sorted in 1.38.
  • Alas, it doesn't look like 1.38a fixed this. In addition, clicking on inventory items in a paused menu now also unhides any On Gameplay menus.
  • Check your PersistentEngine's StateHandler script.  What's the Game State variable set to once you click an item?  It ought to be Cutscene, unless you've set the ActionList to Run In Background.
  • I could be having something similar here.

    This list of actions was working in the last version. 

    If I call the they create the game objects highlighted on the list, but they don't work anymore.

    image

    On the other hand, if I unset the "Pause until finish?" they work again.
  • edited September 2014
    I checked the PersistentEngine gamestate like you advised, and when I click an inventory item it does flip from DialogOptions to Normal (I force the dialogoptions state through code because I want to have the cursor but not pause the game when I open the menu).

    The only thing the items inside do is run an Actionlist on click that has an Object:Send Message action. I tried unchecking Skippable on the actionlists but that didn't help. If I set the menu itself to Pause Gameplay the items do work fine (they are also set to pause gameplay).

  • @JackMariani: Can't reproduce this.  Please re-post this in a separate thread, with more information, about the menus, and when/how the actionlist is run.  Also, please better explain what you mean by "creating the game objects".

    @hedgefield: If you've changed the gameState through code, that's probably why!  If you change AC's code, it's not really an "AC bug" if it causes a problem elsewhere.

    I'm not clear on why you're changing the gameState.  If you could break that down for me better, I might be able to suggest an alternative.
  • Well, I don't want the menu to pause the game and the music, so I can't use the Pause Game When Enabled option, and I can't just have it in the Normal gamestate because then the hotspots behind it are still clickable. So when the menu opens I use MenuSystem.cs to set the gamestate to Dialogue (because I also need the cursor, which is hidden in the Cutscene gamestate, so dialogue is the only option here). Then when you press Back on the menu it sets the gamestate back to Normal.

    This used to work really well up until 1.38, where somehow clicking on inv items and executing their ActionList hard resets the gamestate to the Normal gamestate.
  • The changes had to be made for bugfixing / stability purposes, and this may be a knock-on effect.  But like I said - better to look at the root and see what else we can do.

    Try using the Engine: Manage systems Action to disable Interaction etc when the Menu appears.  This will prevent Hotspots etc from being clickable, but should still keep your Menu active.
  • edited September 2014
    Ah good idea, that eventually helped me work around it.

    Aside from the hotspot problem I also had two persistent gameplay menus which I had to lock manually, and then also move my hotspot interaction menu up in the hierarchy so it would render behind this one, but altogether it gives the same appearance as the old one-stop catch-all dialogueoptions state thing.

    So this is what I added to the menusystem.cs:

    Initialize:
    static private StateHandler state;

    On Start:
    state = GameObject.FindObjectOfType(typeof(StateHandler)) as StateHandler;

    OnMenuEnable - Dossier:
    state.interactionIsOff = true;
    PlayerMenus.GetMenuWithName("Dossier Button").isLocked = true;
    PlayerMenus.GetMenuWithName("Map Button").isLocked = true;

    and then flip those three to false again when the element 'back button' is pressed.



    Woops, looks like that issue kind of hijacked the original point of this thread, but glad to have this one resolved anyway :)

  • I'm still experiencing the issue in the OP with 1.39b.
  • You mean the workaround (MenuSystem code), or enabling menus with Actions?  Does it work again if you remove any scene-based ActionLists?
  • edited October 2014
    Hey Chris, sorry yeah I meant when using the ActionList Assets. I've removed that bit of code and made every menu transition rely on the ActionLists, but moving from menu to menu that way still unpauses the game inbetween, even if both menus are set to Pause Game When Enabled.

    I've tested it during a quiet moment in the game, no other actionlists running in the scene. I press escape > pause menu opens > I open options menu > click back button, actionlist determines this is not the main menu scene so it turns the pause menu back on > game unpauses, throws warning that actionlist could not continue because pause menu was turned on.

    Oh hang on, it seems this only happens when the transition of the Pause menu is set to off. I tried turning the transition back on and checking Pause Until Finished and now it is able to switch between menus fine without unpausing the game (though it still throws the warning that the actionlist cannot continue, but that seems inconsequential since there is nothing left for the actionlist to do after that). 

    I figured leaving the transition off would not give the game the time to unpause between switching menus, but I guess it doesn't work that way ha. I guess that solves it! Cheers.
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.