Animation handling on Scene change

I work on a game where I use timeline animations in Reality Composer Pro.

The game runs in an immersive space, but can be paused where I then move the whole level root entity from the immersive space to another RealityView in a Window Group. When the player continues I do it exactly the other way around to move the level root from the window group back to my immersive space RealityView.

And it seems like all animations get automatically stopped and restarted when the scene gets changed. The problem is, it does not resume where it stopped before, it completely starts again from where it stopped and therefore, has for example a wrong y offset as visible in the picture.

For example in the picture, the yellow sphere loops the following animation:

  1. 0 to 100
  2. 100 to -100
  3. -100 to 0

If I now pause the game (and basically switch scenes), the previous animation gets stopped and restarted at position y = 100. So now it loops:

  1. 100 to 200
  2. 200 to 0
  3. 0 to 100

I already tried all kind of setups - like:

  • Setting the animations relative to root, parent, local
  • Using behaviors (on Added to Scene, on Notification)
  • And finally even by accessing the availableAnimations directly and saving the playback controller of the animation

There I saw, if I manually trigger the following code before switching the scene, everything works as expected:

Button("Reset") {
animationPlaybackController.time = 0
animationPlaybackController.pause()
animationPlaybackController.stop(blendOutDuration: 0.00001)
}

But if I use time = 0 with .stop() directly, the time = 0 seems to be ignored and I get the same behavior as before that it stops in a wrong y offset, hence my assumption that animations get stopped and invalidated once they change the scene.

I tried to call the code manually on ImmersiveSpace.onDisappear, WindowGroup.onAppear and different kind of SceneEvents subscriptions, but unfortunately nothing worked.

So am I doing something wrong in general or is there a way to fix this?

Animation handling on Scene change
 
 
Q