Forum rules - please read before posting.

Checking current GameState via Action

edited July 2023 in Technical Q&A

Hello, is there a way to check the current GameState (i.e. not at "EnterGameState" nor "ExitGameState") via action?

Basically, I've a generic custom script that handles the locking/unlocking of my PauseMenu based on the OnEnterGameState. For instance, if it enters GameState.CutScene, the PauseMenu is locked, when entering GameState.Normal, the PauseMenu is unlocked (and I've various exceptions and stuff).

Now, the issue is with another action which sometimes runs in background at the same time of other cutscenes, and when it's over it unlocks PauseMenu.

So the issue is: the player enters a long CutScene which pauses gameplay and locks the PauseMenu, but the other action in background unlocks the PauseMenu even if that previous CutScene is still going on.

My solution: set a conditional custom action (if a default one doesn't exist) on that background action, that checks the current GameState, and if is "Normal" then unlock PauseMenu, if "CutScene" (i.e. if there's somewhere else a cutscene going on) do nothing (i.e. not unlock PauseMenu).

I guess using the "AC.StateHandler.gameState" is the way to go, but I wonder... If I start a CutScene which pauses the GamePlay, and during that cutscene I run another one in background which ends before the first one, will the gameState return "CutScene" anyway? Or, in other wrods, the AC.StateHandler.gameState, is checking in update if a CutScene is still running somewhere and then returns true to "GameState.CutScene"? And also, if I run this within a cutscene in background, will it always returns true, making it pointless to use in the other cases, or since it's a "Run in Background" the GameState will be "Normal" within the action itself?

Thanks a lot for any guidance on this topic.
Nicola

Comments

  • UPDATE:
    I wrote this custom action and it seems to work... So I guess if an action is running in background it doesn't count as GameState.CutScene.
    Please let me know if it makes sense.

    GAME STATE CHECKER CUSTOM ACTION

  • An ActionList that blocks gameplay will place the game in Cutscene mode, yes.

    The IsGameplayBlocked function, however, can be passed a specific Action ot ignore:

    bool isGameplayBlocked = KickStarter.actionListManager.IsGameplayBlocked (this);
    
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.