sbox-issues icon indicating copy to clipboard operation
sbox-issues copied to clipboard

`Game.ActiveScene.Load( SceneFile )` is breaking `Transform` syncronisation

Open PolSpock opened this issue 9 months ago • 1 comments

Describe the bug

Hi,

For several days, my game & his ViewModel have encountered several transform update issues. Look at this video below: the camera still follows correctly the player's mouse movement but the viewmodel not following correctly.

https://github.com/Facepunch/sbox-issues/assets/5229571/0d7fd96c-d55b-4172-8d51-0b1c8d2017a5

I have been able to spot the issue after an intensive debugging session: I discovered that Game.ActiveScene.Load( SceneFile ) is creating Transform update issues

Let's jump to the reproduction section, I bring you a complete reproduction project and I will explain in more detail

To Reproduce

  1. Download my reproduction issues project: https://github.com/PolSpock/sbox-sceneloaddesync

  2. Lets test the issue: Starts the lobby.scene and click on the button to load the game.scene By starting to move the mouse, you will see that every part is following correctly the camera.

  3. Starts to drop off your brain and toggle Input.MouseWheel and Input.Attack1 simultaneously Your weapons will start to blink (cause the ViewModel camera is toggling off) THEN you will have a strong chance to enter into a unsync Transform of the ViewModelCamera and the ViewModel

This behavior didn't exist before. Also, this issue is strange: I haven't found a way to reproduce it with 100% certainty each time.

https://github.com/Facepunch/sbox-issues/assets/5229571/bfaede4e-3818-41d8-9db7-42532200c02e

  1. If you remove the Game.ActiveScene.Load() logic (so by running game.scene directly), the issue will never occur: this will keep following correctly the Camera.Transform even if you toggle on/off the ViewModelCamera

Expected behavior

Loading a Scene doesn't have to break transform synchronization.

Media/Files

No response

Additional context

No response

PolSpock avatar May 15 '24 19:05 PolSpock