#**How to setup Multiplayer for VR**

1 messages · Page 1 of 1 (latest)

trim robin
#

Hello there, does it have to be a "Headless" "Dedicated Server" instance? What you are describing sounds like the User that creates the room being able to host themselves.

#

It is indeed true that most likely the absolute majority of Unreal Engine developers uses UEs built-in Networking, because it's a First Party implementation, ties into lots of internal code, and is more or less battletested by all the previously released games and Epic Games' Fortnite.

#

And it's also true that there is a big difference between Replication and Online Subsystems. They don't really have much to do with each other, other than being both for Multiplayer.

noble whale
#

As per the logic, user can create their room as a host and others can join just like ShapesXR

#

I was trying to use Unreal null subsystem for local testing, tried writing c++ codes as i want to implement some custom logic in that, but could not make it work, i could not get the localplayercontroller

if (!localPlayer)
{
    UE_LOG(LogTemp, Error, TEXT("LocalPlayer is invalid."));
    OnCreateSessionCompleteEvent.Broadcast(false);
    return;
}

Also what subsystem to use if i want to deploy it to dedicated server, i am on my local university server,
I was thinking unreal's multiplayer would be good as replication and stuffs are relatively easy there, am i right?

trim robin
#

Subsystem is more relevant for your platform needs. Null only allows LAN "Sessions" and direct IP connections. Counts for both ListenServer and DedicatedServer. Hosting PC needs to have ports open if that connection is made over the Internet.

For other online sessions it depends on what platform you are on. I assume you might be using the Quest, so the Oculus Subsystem might be needed for Online Sessions. There is also EOS for cross platform, but not sure it works for Oculus.

#

And yeah for C++ sessions you should check out what I wrote on my blog, pinned to #multiplayer

noble whale
#

I setup the dedicated server, build the two instances, used advanced session plugin that helps me add my custom features, but having trouble with this

I have two levels in my game one for lobby where user select to either create or join the game, as we create the game we get redirected to next level, which is working fine, when user join the session, they see list of active sessions to join from, debug that user joined the room is calling but next level is not coming.

The same i was getting when i didn't pass the ?listen to open level when user is creating the room, but not done here as the server is separate, i am thinking problem is related to this, can you please guide me fro this

#

Also which map should i set to default to server, as one of a tutorial i was following was setting the main game map rather than lobby map as default for server

noble whale
#

@trim robin

trim robin
#

Which map depends on if the players are connected to the Server when in the Lobby or not.

#

A DedicatedServer doesn't need the ?listen part.
Players joining a DedicatedServer session also don't need to use OpenLevel.
The JoinSession Node is usually handling the connecting part in addition to joining the Session.
That's a bit nasty for people who are new to this, cause they assume it's the same thing, but JoinSession itself doesn't actually join the Server.
Or at least it shouldn't. Joining the Session will give access to a URL (as part of the Session result) which the Client then "Travels" to.
Epic combined both into one node (I assume advanced settings does the same), probably to make it easier for Blueprint users.

#

If you do Sessions in C++ by yourself, then you'd need to handle the part where the Client connects to the Server by yourself (or take whatever the JoinSession node is doing).

#

I have two levels in my game one for lobby where user select to either create or join the game, as we create the game we get redirected to next level, which is working fine, when user join the session, they see list of active sessions to join from, debug that user joined the room is calling but next level is not coming.
This reads very confusing because you are using terms where you shouldn't. It's really important to learn the correct terms of whatever you are working with.

Let's assume you have two levels.

  • Lobby
  • Gameplay

If the players aren't connected to the Server yet when they are in the "Lobby" then the DedicatedServer should have the Gameplay map as the default map.
A lot of games have "Lobby" as a Map where players are already connected and see each other in a list of players. That's why the Tutorial probably showed that.
If you call "Lobby" just a "MainMenu" or so, where players still decide if they want to join or not, then that's not the same.

If a Player is in said Lobby and decides to host themselves, given that's an option, then you'd call CreateSession and OpenLevel(Gameplay?listen), as they now want to be a ListenServer (so they listen on a port for incoming connections) and the map they are hosting is the Gameplay one.
To start listening you always need to perform a "Hard Travel", which OpenLevel here does.

If a Player is in said Lobby and decides to join an active game, may it be a DedicatedServer that you are providing, or a ListenServer of another player that is hosting, they would click on said Session in the Session List (if that's how you want to do that), and that would then trigger a call to "JoinSession" node (normal or advanced), which tells the Backend that the Player wants to join the Session, and also creates some local data about the Session.
The Session also contains the URL to connect to the Server, which, as explained, the JoinSession node does automatically after joining the Session successfully. And again, if you were to manually code the JoinSession part in C++, then you'd need to also handle the actual connection.
(Side Note: This does mean you can of course join a session without actually connecting to the Server. That making sense or not is up to the Game and it's requirements. But that only works if you do it manually in C++).

noble whale
#

Thanks for the detailed explanation

I just wanted to confirm if i understand it well, So my logic is users join the game, there they can host the session or join the session out of the active sessions, so when i am creating session i create it with OpenLevel(GamePlay?listen) and when joining it will join as normal,

I understand all but what are you talking about URL, do i need to give one? like in the tutorial they used the localhost url(127.0.0.1:7777) while creating the session?

trim robin
#

users join the game You mean user starts the game executable?

#

Gotta be careful with the terms again here. Joining can suggest you want to join a session.

#

so when i am creating session i create it with OpenLevel(GamePlay?listen)
If you want to allow Players to actively be the Server and you don't care about Cheating, then yes.
The OpenLevel(Gameplay?listen) part is of course absolute pseudo code! In C++ that's probably a ClientTravel and in Blueprints there is a Node call OpenLevel.

noble whale
trim robin
#

when joining it will join as normal
Yes. Joining ListenServer or DedicatedServer doesn't matter. Both work via JoinSession given they both have a Session active.
ListenServers are covered by the CreateSession -> OpenLevel(Gameplay?Listen) part.
DedicatedServers should start on the Gameplay map and need to create a Session somewhere.
In C++ you can make your own AGameSession class which has a RegisterServer function in which you could create the Session.
In BPs you could in theory just use the BeginPlay of your GameMode, but then maybe limit it to IsDedicatedServer.
The AGameSession child class can be specified in a C++ AGameMode child class iirc. It has a overridable function for that.

noble whale
#

Btw i am using blueprints only c++ part was bit tricky for me

trim robin
#

I understand all but what are you talking about URL, do i need to give one? like in the tutorial they used the localhost url(127.0.0.1:7777) while creating the session?
URL is what Epic Games calls this. In Blueprints you don't really see that. It is a bit vague on purpose, because it's not necessarily an IP.
OnlineSubsystemNULL doesn't have Internet Support for Session, so there you can only host LAN Sessions or directly connect to an IP.
LAN Sessions are also kinda fake in the OnlineSubsystemNULL, because there is still not MasterServer + Database that keeps track of Sessions.
For LAN Sessions the asking Player actually sends a message via the LAN's Broadcast IP, which literally asks every connected Device and the one running a Server will answer.
Other Online Subsystems, like OnlineSubsystemSteam, have a MasterServer and a Database that stores Sessions on the "Internet" (keeping it simple here) and that one is asked for Sessions.

noble whale
#

And i did the part OpenLevel(GamePlay?listen), but i am getting the same result, when i create hte session, i get to next level, but when join the newly created session i cant get to next level

trim robin
#

Now when you receive Session Information, it doesn't necessarily contain an IP to connect to. It might for the LAN Sessions, but for Steam it actually hides the users IP and performs the NAT Punch Through (the thing that removes the requirement for opening ports) for you.
When it calls the ClientTravel to connect, it actually passes over the Steam User Id which is inside the Session Information, and the custom NetDriver class (which you usually specify in the ini when setting up Steam) will then figure out what to do with that and potentially ask Steam's backend for the actual IP and connect to that.

#

like in the tutorial they used the localhost url(127.0.0.1:7777) while creating the session?
I assuming you mean "while joining the session".

noble whale
#

This is my create session blueprint

trim robin
#

And that's cause the Tutorial is probably using OnlineSubsystemNULL which can't connect to Online Sessions as there is nothing to host that information.

trim robin
#

Especially if you later use Steam or so.

#

You are telling the Session Backend that you are hosting a DedicatedServer instance.

#

Which this isn't.

#

This is your "Player is a ListenServer" code.

#

So that boolean shouldn't be checked.

#

For Steam you also can't have DedicatedServer and Presence enabled at the same time, as Presence is a "User" concept (it allows joining via the Friend List for example), which isn't a thing for some Headless Server.

noble whale
#

so i should disable the dedicated server boolean, right?

trim robin
#

Yes

#

Are you using Steam?

noble whale
#

ok let me try

noble whale
trim robin
#

Then you can't host Online Sessions

#

You need to enable "LAN" on the CreateSession Node.

#

And you need to join this via the JoinSession Node. You can't use open localhost via the console.

#

That won't join the Session but only connect.

noble whale
#

I am making this multiplayer for vr, so will steam be needed for that?

trim robin
#

VR is not the point for needing Steam or not.
Online Sessions are.

#

If you want two Players on the opposite side of the World to Host and Find each others Sessions, then you need an Online Subsystem that supports that.

#

If your VR Game runs on the PC and uses a VR Device connected to the PC, then Steam or EGS (Epic Games Store) are options.

#

If your VR Game runs on a Standalone Device, like the Quest 2/3, then you probably need to look into the OnlineSubsystemOculus or whatever it is called by now.

#

Or whatever Subsystem maybe exists for your Device.

#

The OnlineSubsystem provides you with the MasterServer + Database that you need to Host and Find Sessions.

#

You can also sit down and code your own :D but that's a lot of work.

noble whale
trim robin
#

You do, of course, need to sell your product on the Store that you want to use the Subsystem of.
E.g. you can't use Steam without selling on it.

trim robin
#

I think they have a custom fork of the engine you might need to download and build

#

But unsure.

noble whale
#

I was following this tutorial, he didnt specified to enable any subsystem, how he is able to do so then?

trim robin
#

Do what exactly?

noble whale
trim robin
#

But you better ask VR peeps about that.

noble whale
trim robin
#

All his Login button does is connect directly to 127.0.0.1.

noble whale
trim robin
#

You don't need Sessions to do that.

trim robin
#

His DedicatedServer, when started, is automatically listening to port 7777 on the local machine.
If he would open his 7777 Port and tell someone his public IP, others could connect with that.
But that requires opening Port(s) and sharing the public IP to everyone by hand.

#

Sessions are a concept to remove that whole thing. Server tells some MasterServer "Hey, here is my Session, here is some information about it, like the Level, my IP/ID, how many players can join, etc."

#

And the players ask that MasterServer for a list of all those Sessions.

#

You don't need Sessions to connect to a Server.

#

They are information bundles.

noble whale
#

Oh okay

trim robin
#

But again, without Sessions, especially from OnlineSubsystems with proper Internet support, you have to do everything manually.

#

Open Port(s), share Public IP.

#

No list of possible games.

#

The Open Ports and share Public IP is of course redundant for the Tutorial you linked as he just connects to his own PC.

noble whale
#

And for replication as well i guess?

#

i would need onlinesubsystem

trim robin
#

No, Replication has nothing to do with that.

noble whale
#

@trim robin hey

#

I researched and found i could use eos, with source code for oculus, so first i am setting eos with a tutorial, did the steps and package the game but it is not opening in the windows pc

#

Can you help me diagnose this as i tried doing but could not find the posssible issue

trim robin
#

You'll have to post about that in the matching channels. I haven't worked much with EOS and Oculus, so I can't help there.