Adding VR Multiplayer to UE5

Introduction

So, you want to make a multiplayer application in Unreal Engine, in VR. I did quite a bit of research on this topic, and found that currently there's no super 'nice' way to make it work, that's free. Unlike Unity, which has access to some free hosting plugins, or has native support for plugins that integrate directly with Unity's system and some servers, Unreal Requires a bit more work.

I found that Photon allows you to connect to their cloud server for free, with a bandwith cap and maximum number of connections. While looking into the server service, I found that Photon has Unreal Engine support, but only through their SDK, which could require some previous programming knowledge and a bit of time to get everything working nicely, which is something that I didn't have the time for while working on my projects.

I found this plugin, which packages everything nicely into Unreal Engine to work with photon cloud, and connect with your own free server. The only drawback is that it's $50. However, it seems to work pretty okay as a plugin.

The next sections use this plugin in order to get multiplayer to work nicely. Maybe a fun project would be working with the Photon SDK and releasing an open source version that allows people to integrate multiplayer with Photon cloud?

Important Tutorials:

I used one main tutorials to get multiplayer in VR. The main tutorial refers back to another tutorial multiple times, so I'll link that here too.

Adding Multiplayer VR to UE5 (The Gabmeister): https://thegabmeister.com/blog/unreal-vr-multiplayer-photon/

Adding Multiplayer to UE5 (3rd-person mode, Non-VR): https://thegabmeister.com/blog/unreal-photon-multiplayer/

Unreal Engine 5 Multiplayer FPS Tutorial Part 1/2 - Photon Cloud - https://www.youtube.com/watch?v=mL5cf8M4RRk

Unreal Engine 5 Multiplayer FPS Tutorial Part 2/2 - Photon Cloud - https://www.youtube.com/watch?v=ywI7vmxhaz4

Adding Teleport & Snap Turn to UE5 VR Multiplayer Pawn

One of the shortcomings I ran into while using the VR multiplayer Pawn that I created using the above tutorials was that they were unable to interact with the world. They are unable to move, grab, or interact with items in the world. I didn't have the time to implement grabbing in the VR world, but was able to add teleport and get it working in a multiplayer sense.

An aside: Teleport in multiplayer VR isn't a great implementation of movement. Due to the nature of needing to follow people sometimes in VR, having people teleport and jump around (sometimes possibly out of view) can make it extremely difficult to follow targets. I'd recommend that you implement some sort of smooth movement into your pawn (here's a tutorial I tried, but couldn't get to work), so that people are able to see movement of player. A workaround to this would be having some sort of 'animation' between movements client-side to give a sense of direction in teleport to the user, to make it easier to follow.

This section assumes that you've setup the Custom VRPawn actor in the same way as the first tutorial above.

Part 1: Setup

Part 2: Copying Blueprint Components

You'll need to copy the following items:

Select all of them, and copy them into the components of BP_VRPawn that you created. Arrange them accordingly:

Check the variable names for each imported item. Ensure that none of the imported components have spaces in their variable names. Hitting 'compile' for the entire system should yield no errors.

Part 3: Copying All The Needed Blueprint Functions

For example, in IsAxisGreaterThanDeadzone, compiling leads to the following error:

Simply right click the missing variable, press 'Create variable', and UE will add the variable for you. Make sure to recompile everytime you make a change. It should fix most issues. Do this with all of the missing variables. Make sure you compile after every addition, as it may clear duplicate errors.

Note: make sure to right click outside of the word, but still inside the code block. Different menus may show up depending on where you click. In the above example, click outside of 'Axis Deadzone Threshold', but inside of the box.

Also: Snap Turn Degrees in the 'snap turn' function should be set to 45 degrees, or however much you want to snap turn by.

Adding all of these variables will fix any compilation errors. Once that's done, the blueprint should compile successfully, and you can move onto the next section.

Part 4: Adding to BP_VRPawn's Event Graph