How can we set up Multiplayer for a VR game

Hi all,

I work in the world of architectural visualisation. We’re trying to create a virtual reality walkthrough for 4 people simultaneously in the same space. Basically a multiplayer VR setup. We’ve got four HTC Vive headsets with the wireless adapter. 4 suitable Pc’s too in the same office, so the client doesn’t have to remote connect. Thus far I’ve worked more as a Game artist, animator, content creator rather than developer or coder with UE4, but I understand basic blueprints, replication, some of the basics of client and server setup.

I need some help or breakdown on best practice on how to setup and get 4 VR headsets running simultaneously through a singular game level. Thus far the level is modelled & baked, Pawns are there and working correctly with the VR motion controllers with a single user. In the past I’ve just created exe standalone from UE4.

Where I’m stumped is that you can’t connect 4 HTC vive headset’s to a single PC. They each have to have their own, so how do I get the 4 VR headsets talking to each other and interacting with the game?

•What would you guys recommend in order to get this working for multiplayer VR?
•What kind of replication project and pawn settings do I need to be aware of?
• What do I need to understand with regards servers and framework setup?

UE4 settings are oriented to a listen server as I my skillset found this easier, but open to dedicated server setup if it’s more logical or required. I realise I’m being a bit broad with the info (trying not to sound too much of a noob) happy to try and provide more specifics. Finding info very sparse so references or tutorials welcome. Basically I want help completing this sentence

" The simplest way to get 4 Vr headsets running in a UE4 generated game is to…"

1 Like

good luck getting a proper answer other than ‘use VR Expansion’ plug-in

I work in a similar field and I dont use the VR Expansion Plugin lol

My current working set up uses a listen server and up to 4 connected clients. The connection method is done via peer-to-peer direct IP connection. The first consideration is to make sure you use the ?listen flag when opening a map, so the connection command will be “open LEVELNAME ?listen”. This happens automatically at OnPostLogin in the game mode. The default map is the one I use in MP, but the OnPostLogin event reloads the map with the flag to make it accessible over the network. I handle the connection with controller-operated widgets, basically a keypad with a ‘join’ button that executes “open XXX.XXX.XX.X” where the X’s are the IP address of the host machine. You can also do all this manually via the console if you choose. Note that youll have to do this whether youre on a local network or the internet, but if youre doing it with the internet youll need to have your network configured to forward certain ports.

Replicating the VR-related components was an absolute nightmare with the default (pre 4.27) template, because for some wild reason the player pawn spawns its motioncontrollers at BeginPlay in the form of other blueprint actors, which causes so many problems for replication it stopped being funny real quick. Instead, add motioncontroller components to the player pawn, assign them to the appropriate hands, and make your hand/controller meshes children of those components. This makes it 100000% easier to replicate these actors in a way thats predictable, makes sense, and aligns with official documentation.

Also, for some reason, no matter which ‘spawn the player properly at the server level’ configuration I used, this is the only method that worked: Start at the OnPostLogin event in the gamemode. This event has a ‘New Player’ output, representing the latest player controller thats generated when a client connects. From that output, cast to your playercontroller actor and execute a ‘ClientLogin’ event that youll have to make yourself and set it to Run On Server. In this event, cast back to the gamemode and execute a Run On Server event (Called something like “Respawn Player”, youll have to make this yourself too) that takes in the player controller as an input. At this event, use a spawnactorfromclass node to spawn the player pawn, then a possess node with the return value of the spawnactor node as the ‘In Pawn’ input and the player controller output from the event as the ‘Target’.

Gosh I hope that makes sense lol. Doing it this way ensures that clients can connect and have a pawn that exists on the server.

Here’s the snippet that I use to replicate the hands and head locations/rotations:

The ‘SendControllersToServer’ event is run on event tick in the player pawn (all these events are in the player pawn). The components in question need to be set to replicate, as well as the pawn itself. Its worth noting that it wont work if you grab the transforms in the server event; the data that you want to replicate needs to passed into a server event and then used as inputs for the transform nodes.

This should hopefully get you up and going :slight_smile:


Really need to consider doing some blending and lowering the send rate on those, sending full transforms on tick is going to be very bandwidth heavy.

1 Like

Oh yeah, absolutely. In practice I have all replicated variables in a struct and package floats 3-at-a-time into net vectors, but this works for the sake of example.