sbox-issues
sbox-issues copied to clipboard
`Game.ActiveScene.Load( SceneFile )` is breaking `Transform` syncronisation
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
-
Download my reproduction issues project: https://github.com/PolSpock/sbox-sceneloaddesync
-
Lets test the issue: Starts the
lobby.scene
and click on the button to load thegame.scene
By starting to move the mouse, you will see that every part is following correctly the camera. -
Starts to drop off your brain and toggle
Input.MouseWheel
andInput.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
- If you remove the
Game.ActiveScene.Load()
logic (so by runninggame.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