Search code examples
unity-game-engineunity3d-unetunity-networking

Unity VR UNET make PC and VR the same player


Sorry that there is NO CODE to show, but this is a very architectural question.

First of all, I have to say that i have to use UNET and yes, I know it is deprecated, but i'm not doing an actual network game that will let users join the game. I will explain: I have a project that is connected to hardware. The PC is running the Unity brain that controls the hardware and receive info from it and so on. This part is working great.

The thing is that I need to connect Simple VR glasses to look around (JUST FOR LOOKING AROUND AND "PRESSING" the start button) and nothing else, everything will still be controlled by the PC (That will run a UNET server if needed) and the main client that moves and get inputs and do things, And the VR need to be a "Slave" of sort just for looking around. I want UNET because the unity used for the project is 18.3.14f1 and yes, I know that it is old but it is a legacy that i can't change as for now and I don't need a could server as all the hardware is in the same LAN.

From what i can understand, In Client / Server every client (PC AND VR) SPAWNS a new client so when client in the VR will not have the same client that is on the PC. That is making things very complicated.

Can I have some kind of a MASTER / SLAVE thing that will control both? If NOT should I do everything on the server and send everything to both the clients? Or should I still have the regular approach and send every thing from on client to the other (change all the code in the app)?

Couldn't find an answer for that, I don't think it is a very used case scenario.

10x.


Solution

  • First of all, I have to say that i have to use UNET and yes, I know it is deprecated, but i'm not doing an actual network game that will let users join the game. I will explain: I have a project that is connected to hardware. The PC is running the Unity brain that controls the hardware and receive info from it and so on. This part is working great.

    You can use Mirror so you won't run into trouble when Unity removes UNET from the engine.

    The thing is that I need to connect Simple VR glasses to look around (JUST FOR LOOKING AROUND AND "PRESSING" the start button) and nothing else, everything will still be controlled by the PC (That will run a UNET server if needed) and the main client that moves and get inputs and do things, And the VR need to be a "Slave" of sort just for looking around.

    That's not how UNET works. The basic idea is that the game runs simultaneously on every device. Your VR Glasses will have to run the game to be able to render it. With UNET you just sync the game state and make sure every connected instance has the same state.

    From what i can understand, In Client / Server every client (PC AND VR) SPAWNS a new client so when client in the VR will not have the same client that is on the PC. That is making things very complicated.

    Can I have some kind of a MASTER / SLAVE thing that will control both? If NOT should I do everything on the server and send everything to both the clients? Or should I still have the regular approach and send every thing from on client to the other (change all the code in the app)?

    Every connected device can spawn a new Player on every connected instance of the game. I think this will help you to differentiate between the VR Glasses and sync states between the clients.

    Couldn't find an answer for that, I don't think it is a very used case scenario.

    You are not locked-in to UNET. Sometimes it is feasible to setup your own TCP- or UDP-communication.

    The description of your UseCase is not clear. Should ever VR Glass run independent and you want the PC to have all workload? Or are the VR Glasses are connected to create a shared experience? What is the role of the PC? What should be shown there?