Skip to content

frame advancing in-game #238

Open

Description

@Eddio0141

When to pause

  • I need it to pause on both update and fixed update as the user wishes
  • I should pause before the events happen

How to pause

  • I already have code to pause MonoBehaviour so I can use this to pause and unpause the game
  • On PreUpdate, before any UniTAS operation is done, check if game needs to be paused or not

How to unpause

  • I need to sync update offset with when it was paused
    • For example, if paused before FixedUpdate, this means FixedUpdate has yet to run and (assuming update happens with perfect timing), the offset would be 0
  • By reusing code that I use to restart the game, I should be able to sync the update timing to the right offset and continue running the game

While paused

  • Keep fps at config's fallback fps value as unpausing will handle the update offset problem

Pause state tracking

  • I could have an enum of the timing of when the pause happened
    • So either Update or FixedUpdate in my case

Pausable coroutines

  • I need to track all running coroutines
  • What I could do is modify IEnumerator firstly to not run MoveNext when paused (which doesn't update Current so I have control over that)
  • Coroutines have a Current to express what is the next wait period, so while paused, I can force return this property to whatever is the next coroutine yield (like for update pause, yield null) for all coroutines
    • So when pause happens, I need to store all Current for the coroutines for restoration later on
  • MoveNext can be invoked by unity specified by the event execution order
  • As for WaitForSeconds and WaitForSecondsRealTime, because these callbacks only happen after some time, i can't "pause" them so I have to modify their behaviour to be the exact same BUT waiting for n frames instead with a custom tracker for this
  • For WaitUntil and WaitWhile, I need to figure out timing on when they get yielded, but they should work fine with the normal hijacking as they just check for a condition and while paused, nothing should change

Tasks

I modified ISyncFixedUpdateCycle.OnSync to also allow for waiting at any index of FixedUpdate too

  • Test ingame with logs
  • Test with tests debug prints with UniTAS and watch out offset
  • Test with external tool, and make sure it passes

Activity

  1. pinned this issue on Jul 18, 2023
  2. linked a pull request that will close this issue238 frame advancing in game #246on Aug 3, 2023
  3. Eddio0141 commented on Oct 28, 2023

    @Eddio0141
    OwnerAuthor

    not complete yet, check list

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions