Search Unity

How can I ignore Enemy's camera\controllers with netcode?

Discussion in 'Netcode for GameObjects' started by ErezShahaf, Apr 20, 2022.

  1. ErezShahaf

    ErezShahaf

    Joined:
    Feb 3, 2022
    Posts:
    70
    I currently have two players in the server, each has it's own open XR rig (VR sensors) and a camera.
    For some reason, even though in the NetworkObject of the camera each player only has ownership of it's own camera, whenever a new player enters they overwrite all the other cameras and everyone sees through that new camera. I have tried to implement in the code a statement that checks as a client which cameras you own and if you are not the owner it uses
    Code (CSharp):
    1. playerCamera.enable = false;
    , but to my surprise whenever the client uses it for itself, it will also disable the camera for the player that should be using it.

    I have the same issue with the VR sensors, whenever one client moves their hands it will move everyone's (Because one VR controller moves all the open XR rigs in the scene) even though they do not own the networkObject. I think that in Photon Engine there is an option to choose if some objects are setActive to a specific client. But I couldn't find a way to do that with netcode.
     
  2. hoesterey

    hoesterey

    Joined:
    Mar 19, 2010
    Posts:
    659
    Can you only spawn the XR rig on the "Local" client and have network objects spawn that are purely visual for other players? That is how I'd handle it.
     
  3. ErezShahaf

    ErezShahaf

    Joined:
    Feb 3, 2022
    Posts:
    70
    Well, I did try it - but for some reason the inverse kinematics didn't react to that well. I may try it again but if there's a setting for that in netcode it would be preferable