Best Practice Pause and Resume for Characters, Cameras, and Objects

I have a GamePlayManager where I'm able to pause/resume gameplay for 1-4 UCC characters. It works well and the current (possibly naïve) implementation is:

C#:
private void OnGamePause() {
    foreach (var locomotion in uccCharacterLocomotions) {
        locomotion.TimeScale = 0;
    }
}

private void OnGameResume() {
    foreach (var locomotion in uccCharacterLocomotions) {
        locomotion.TimeScale = 1;
    }
}

I now want to ensure MovingPlatforms pause/resume too. This led to me digging into the KinematicObjectManager. From here I realized there are likely three types I need to pause/resume:
  • KinematicCharacter
  • KinematicObject
  • KinematicCamera
Since each UCC character has its own TimeScale, toggling it between 0 (pause) and 1 (resume) has worked well. However, I'm now under the impression that using the various Register/Unregister methods (for each of the three kinematic types) might be preferable.

@Justin As the author of UCC, I'd like to know:
  1. What is the recommended approach for pausing and unpausing gameplay that takes into account the three kinematic types?
  2. Is there anything outside these three types that I need to consider when pausing/resuming UCC related gameplay?
 
Last edited:
I refactored my approach to handle the three kinematic types in a much simpler way. My pause/resume handlers are now simply:

C#:
private void OnGamePause() {
    kinematicObjectManager.enabled = false;
}

private void OnGameResume() {
    kinematicObjectManager.enabled = true;
}
 
@Justin So I ran into a bug related to my above kinematicObjectManager.enabled pause approach. It turns out that disabling results in the instance being nullified if there is a scene unload change. Thus, when another opsive manager tries to access the KinematicObjectManager upon pause resuming, it runs before my code reenables it. This results in a duplicate KinematicObjectManager (a new one that is not the default one that's auto generated via the SetupManager). Naturally I get borked UCC behavior as a result.

This wasn't an issue previously as I didn't have scene unload changes happening which meant that the instance was never nullified. With a UI scene and a streamable world of scenes this is now an issue when a pause happens. As a result my initial two questions resurface:
  1. What is the recommended approach for pausing and unpausing gameplay that takes into account the three kinematic types?
  2. Is there anything outside these three types that I need to consider when pausing/resuming UCC related gameplay?


Below are snippets from KinematicObjectManager

1642260038033.png

1642260065297.png

1642260174552.png
 
@Justin Additionally there is no API to read the array of current:
  • KinematicCharacters
  • KinematicCameras
  • KinematicObjects
to even foreach and "pause" (where each type currently would need a different way to pause as I see it). Am I missing something obvious and/or overlooking something? It seems like there should be a built-in way to exclude all three types from processing in a pause game type scenario.
 
Top