#**How to setup Multiplayer for VR**
1 messages · Page 1 of 1 (latest)
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.
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?
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
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
@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++).
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?
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.
TheOpenLevel(Gameplay?listen)part is of course absolute pseudo code! In C++ that's probably aClientTraveland in Blueprints there is a Node callOpenLevel.
yeah user start the executable
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 theCreateSession -> OpenLevel(Gameplay?Listen)part.
DedicatedServers should start on the Gameplay map and need to create a Session somewhere.
In C++ you can make your ownAGameSessionclass which has aRegisterServerfunction in which you could create the Session.
In BPs you could in theory just use theBeginPlayof your GameMode, but then maybe limit it toIsDedicatedServer.
TheAGameSessionchild class can be specified in a C++AGameModechild class iirc. It has a overridable function for that.
Btw i am using blueprints only c++ part was bit tricky for me
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?
URLis 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.
OnlineSubsystemNULLdoesn'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 theOnlineSubsystemNULL, because there is still notMasterServer + Databasethat keeps track of Sessions.
For LAN Sessions the asking Player actually sends a message via the LAN'sBroadcast IP, which literally asks every connected Device and the one running a Server will answer.
Other Online Subsystems, likeOnlineSubsystemSteam, have aMasterServerand aDatabasethat stores Sessions on the "Internet" (keeping it simple here) and that one is asked for Sessions.
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
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".
This is my create session blueprint
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.
You need to be careful with the Settings on that.
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.
so i should disable the dedicated server boolean, right?
ok let me try
no
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.
I am making this multiplayer for vr, so will steam be needed for that?
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.
its standalone, so i guess i need to enable onlinesubsystem for quest, and do i need to do something after that as well?
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.
That's beyond me and probably better asked in #virtual-reality or openly in #online-subsystems
I think they have a custom fork of the engine you might need to download and build
But unsure.
Building Dedicated Servers with Unreal Engine 5
00:00 Intro
00:49 Create New Project
02:34 Create Main Menu
08:12 Level Blueprint
10:03 Project Settings
11:26 Server and Client Build Targets
14:37 Packaging builds
16:24 Launching and Connecting to Local Server
Links:
Setting Up Dedicated Servers
https://docs.unrealengine.com/5.2/en-US/setting-...
I was following this tutorial, he didnt specified to enable any subsystem, how he is able to do so then?
Do what exactly?
Yeah i have did that, bcz i couldnt build without building source code
Unreal Engine Source Code is required for building Dedicated Servers, correct.
But what I mean is that Oculus, or Meta, have a custom version of that.
But you better ask VR peeps about that.
he setup the dedicated server, but not created any session or stuffs just get to second level as he clicks the login button
All his Login button does is connect directly to 127.0.0.1.
I didnt knew multiplayer is different for vr and other
You don't need Sessions to do that.
It might be. I just remember that Oculus had a custom Engine version.
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.
Oh okay
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.
No, Replication has nothing to do with that.
@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
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.