Question about Collaborative Sandbox Sample

Hi, hoping you’re doing well : )
I have been checking the networking samples and the sandbox one caught my attention. Because when one player joins into the network room , each player have their own camera without the need of using an object with the PlayerSync which instantiate a Player Prefab with a Player State component. So I suppose that Player Prefab instance is"generated" using the Synced Camera, could you explain me is how does the Synced Camera script works broadly ? Also, which script is responsible of switching the camera when a player clicks another’s Camera Prefab ?

Thanks : )

Original Post on Discord

by user 632418299711324161

Hey :wave:

The SyncedCamera scripts does:

  • spawn a prefab per every remote player
  • synchronizes position and rotation

The possessing of other users is done by SpectatorCamera script.

The SyncedCamera is historically a bit older component and does similar logic to what PlayerSync/PlayerState do itself internally. At some point we’ll likely unify these so that they have the same codebase

Phrased differently, you could build SyncedCamera with PlayerSync/PlayerState too

Thanks to both, really : ) Another question, what does this method do SyncedTransform.requestOwnership(); ?

by user 632418299711324161

Requesting ownership does set that specific instance as the owner, and then the position and rotation is sent to the same object in other sessions.

In other words, without calling this method, synchronization won’t occur.

Perfect, thanks kipash.

by user 632418299711324161

Another thing, Is there any way to know when a player is in VR mode ?

by user 632418299711324161

this.context.isInVR
this.context.isInAR
this.context.isInXR

Also if you want to just enable disable game objects based, check out hte XR Flags component :+1:

Thanks : )

by user 632418299711324161