Hello fellow developers,
I’m very new to Unreal and trying to understand it’s parts in very limited amount of time.
At the moment I work on building Room System and sort of Lobby system for clients to find games online and join them, so far I have broken down Shooter Game example and think that I sort of get the flow of such system:
this is something I’m trying to build and right now I’m experiencing a lot of small problems with this system - From lack of documentation and general Unreal knowledge.
I guess my question is: Is there any good read/watch tutorial online on how to build something like that. Or at least useful tips that you guys can give me for future.
Disclaimer: Writing this from memory so will probably be off a bit since I don’t know what I’m doing either.
You won’t find many helpful resources online since no complete explanation exists. You have to make sure you include the right dependencies first off; for public: OnlineSubsystem, OnlineSubsystemUtils, OnlineSubsystemNull, for dynamic: OnlineSubsystemNull. Substitute Null with any other subsystem if that’s what you want to use; like Steam. In your DefaultEngine.ini you will need something like:
[OnlineSubsystem]
DefaultPlatformService=Null
Then in your gamemode or such whenever you want to get a runtime pointer for the online subsystem:
You can then use the appropriate methods to create, find, or join a game (CreateSession(…), FindSessions(…), JoinSession(…)). For most of the functions the player ID can be 0 since the engine doesn’t do anything with it at the moment. The delegates you can just set all at once in a function like BeginPlay() - just copy how ShooterGame does it.
For some reason you have to set your game session class in this strange manner even though everything else is as simple as setting a variable in game mode’s constructor.
Anyways you need to derive your own game mode and overload GetGameSessionClass like I did above. Then when you call:
Thank you! I will surely try this out today.
All i’m doing is trying to repeat ShooterGame example from Unreal. but most likely you’re right on that I’m over complicating it.
To be honest for the time being I’ve considered forgetting the online subsystem. I tried to analyse ShooterGame and at least get OnlineSubsystemNull running. I can create sessions, but when I try to find them everything goes awry. There’s no proper documentation either so I rather not age 20 years trying a million things to make it work. At the moment if I want to dabble in online subsystems I’ll probably stick to BP since it seems more straightforward - setting delegates is a billion times easier thanks to the Success/Failed? nodes, hopefully they’ll simplify it for C++ as there’s just too many steps to remember.
Alternatively you can just use the ServerTravel and ClientTravel functions in C++. This works on local/LAN/Internet. Only problem is there’s no master server support as well as the many other nice features you get from the online subsystems.
Edit:
I’m hoping someone could tell me why setting a delegate wasn’t made as simple as MySessionPtr->CreateSession(0, “SessionName”, this, &MyClass::CallThisWhenCreated, &MyClass::CallThisWhenFailed). The advantage here is that I don’t need to remember 4 or so extra steps for Unreal’s custom delegate system.
Hey there, i just wanted to tell you guys that i plan to get a basic Host Search Join Setup running in c++ and make a small tutorial plus documentatiom about it. I already understood most of the session things and we all know that we need docs about it. It is pretty simple in BP with the nodes but since it is that simple, you can’t really extend it (there is an advanced session nodes Plugin though).
Till now i had no time, but since i need this for my own game, i will try to get this up over the few days/weeks.
I will open up a thread then to gather questions and help, for the parts where i may get stucked (i hope i won’t).
thank you, such thing in C++ would be extremely helpful.
MaxL - Man I cant thank you enough, you were 100% right. I did not override GetGameSessionClass() in GameMode and that is what been driving everything bad. I got it to whatnot work yesterday. You should have seen my happy dance
when I try to chase current game session with using this function on the server(master client) it works just fine. But when I try to use this logic on client it breaks the code with “trying to access NULL” on the first line.
Can you please help me? do you know what is the difference between server and client logic for that function?
I can. “GetAuthGameMode()” does not work on Clients, because only the Server has an instance of the GameMode Class. There simply is no spawned GameMode for clients.
Very important to know! (: