Forum rules - please read before posting.

Pause/Unpause Via Script

Hey all,

I've been working on controller remapping, which uses coroutines.

I've found that this works fine in the main menu of the game but not in gameplay. I believe this is due to the state of the game being "paused".

If I set the Pause Menu to not pause gameplay, this works fine and fires off the coroutine and allows me to remap.

Is there a way through code to unpause/pause the game? If so, I could unpause on the button press, and repause when the button has been mapped. I'm not sure if this would cause a conflict with the "Pause game when enabled" feature of the pause menu is on though (fighting for control, etc).

Or if anyone knows another way to run a coroutine while AC gamestate is paused, I'd love to know.

Thanks!

Comments

  • You can affect the StateHandler script's EnforcePauseMode property, but this only forces AC into a paused mode - setting it to False won't have an effect if the game is already paused due to a Menu being on.

    A coroutine should work fine while the game is paused however - you can use Unity's WaitForSecondsRealtime class to ignore the timescale.

  • This worked a treat.

    I knew it would be something simple, thank you so much Chris!

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.