Is there a trick to using WorldUpOverride in a networked game?
I currently have a VirtualCamera with a Transposer that swaps between LockToTarget (player not moving) and SimpleFollowWithWorldUp (player moving) and need to be able to set the WorldUpOverride to a child of the player object since the player’s gravity direction can change. The target object for the virtual camera is the same transform that I’m trying to set the WorldUpOverride to. It uses a custom script to always remain “upright” opposite from the player’s current gravity direction which would make it ideal to use as the “up” direction for the camera.
This seems to work perfectly on the host but remote clients seem to always report a WorldUp value of Vector3.up regardless of what the WorldUpOverride transform rotation is set to.
Tracing it out seems to show multiple calls to UpdateVirtualCamera in the CinemachineCore class where the correct worldUp value is present but they are discarded before vcam.InternalUpdateCameraState can be called. The call that ends up fully running always seems to use the fallback Vector3.up value instead.
It’s a bit confusing since the camera itself is actually not networked. All clients just happen to have an identical camera pointing at a child transform of the same networked player GameObject and yet WorldUpOverride won’t work on remote clients despite it being set properly on the CinemachineBrain and the bindingmode correctly changing to SimpleFollowWithWorldUp.
I’ve also tried having a WorldUpOverride transform that isn’t a child of any object but would mimic the same behavior as the previous one setup to see if being a child of a networked object was the issue but it acts the same. It seems like WorldUpOverride is completely broken on networked clients for some reason.
Attached are a couple of screenshots from sticking a Debug.Log on the worldUp value at the beginning and end of UpdateVirtualCamera while the player and WorldUpOverride transform were inverted. The (0, -1, 0) vector should be the one that is used but it isn’t working and defaults back to (0, 1, 0) for some reason.
This is using Mirror 19.02, Unity 2020.1.5f1 and Cinemachine 2.6.3 if that makes any difference. CinemachineBrain update method is still set to the default of Smart Update but using Late Update makes no difference.