Search Unity

Question How to View Through Another Player's Camera?

Discussion in 'Multiplayer' started by chris-tdc, Jan 30, 2021.

  1. chris-tdc

    chris-tdc

    Joined:
    Dec 11, 2020
    Posts:
    19
    Unity 2020.2, OpenXR Rig, Mirror

    Hello. I am developing a multiplayer VR experience where a single player running a Windows build with a VR headset (OpenXR Rig) explores an environment and I want other 'players' to be able to join the session from their web browsers and see through the eyes of the VR player.

    I see potentially two approaches and I would really value any experience or opinion on which way to pursue please?
    1. Enable the Web Viewer to actually see through the camera spawned in and belonging to the VR Presenter.
    2. Enable the Web Viewer's camera to be synchronised with the VR Presenter's camera in their OpenXR Rig.
    It's all new to me and I currently wonder if somehow I can use Mirror's NetworkTransform to keep the cameras synchronised.
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    I'd probably just sync the position of the player's camera to the other participants. Then on the viewers you just position the local camera to match the synced position, lerping between synced position updates. That can be done with just RPC's/Commands. Normally you wouldn't make the camera itself a networked GameObject.
     
    chris-tdc likes this.
  3. chris-tdc

    chris-tdc

    Joined:
    Dec 11, 2020
    Posts:
    19
    That's very interesting. So should my player prefab have an OpenXR Rig in it and somehow on each client I identify if the player is VR Presenter (in which case they 'drive' the camera using their Vive Headset) or a Web Viewer (in which case I sync the camera in the OpenXR Rig to match the VR Presenter's camera)?