Hello dear community,
i would like to know where to start to be able to start a network session.
My first test is a simple GUI for 2 clients, with a few buttons.
My gamelogic and gui is already finished, means i know what the buttons do, and i can handle what happens between 2 player.
Unfortunately i have no exp in setting up a network comm in ue4 so i need your help here.
Intentionally i thought about this:
A Player who has the game installed opened it and is presented a MainMenu.
- Player can Host a new Session, so remote Player can connect to it.
- Player can connect to a Session if there is any.
I think if i choose Host option, would mean this Player will become Authority, and the GameMode from this Player becomes the Server, right?
If we choosed Host -> I present a simple GUI which just has a throbber and a Text “Waiting for another Player”
So if a second client opens the game on his local machine he would choose Search for Session.
He will become the Remote Authority then if he reaches our session and our local Gamemode would create a new Player (the remote).
Now the session would be created and both Player share the same GUI, or having one for themselfes.
are these intentions a good way to go?
What should be done in a GameMode BP?
Do i need a GameState?
How would a remote client request for a login on our GameMode?
Is the test Server configured with 127.0.0.1?
Create Session -> is there a Session derived Blueprint in order to say what happens inside a session?
What are the responsibilities of Session and GameMode?
Sorry for so much questions. I would like to understand this stuff. So i appreciate any textual explanations or image examples.
best regards
ok then maybe someone can help me if im going step by step:
The first task is, create two players and assign both an own UI:
So i did that first, unfortunately crashing the game
(Mode and Player is set up in Project settings, run with 2 clients, unchecked ded. Server)
[ATTACH=CONFIG]GameMode[/ATTACH]
[ATTACH=CONFIG]PlayerController[/ATTACH]
Using Self will cause a crash because it takes a little while for things to catch up. Try putting a small delay before creating the UI. You could also look at the networking twitch stream, it doesn’t cover everything but it uses the GameInstance Class to handle the UI for the menus. https://www.youtube.com/watch?v=4LV7KKtzKs8
omg, thanks for an answer. I thought i would be left alone. And thanks for the hint i will test them when im back home. Also thanks for the link.
Hi,
I use (and it’s a lot easier) the HUD class to create my UMG widgets, and i also use a very small delay (0.01) to not get a failed cast (it needs a few frames for the pawn to be initialized i guess). Im also learning to do a multiplayer game, i haven’t done the game session yet, only replication stuff. You can check the ShooterGame example it has a lot of mutiplayer stuff, you can get all the answers you want from it but it has a lot of c++ so it can be difficult is you only work in blueprints.
Hey, there thanks for your response. I think i will check the shootergame out, though its c++ only i think, but that doesnt matter.
However, i would never use the HUD Class to do more than drawing primitives in most cases. First is, AHUD has a PlayerController (1:1), every widgetinstance has a playercontroller (1:1) and
if i add the widget to viewport, means get Controllers HUD and add the widget regarding its options. Since a widget creation always asks for a Controller it is far simplier to do the creation there.
If i would use the HUD for that, would mean i need connections between classes which are not intended to be.
Btw. i have different Menus running, KeyBind System, Inventory… there is not a single node/code inside my HUD.
You can also checkout my MVC Tutorials for that. If you want :).
https://www.youtube.com/watch?v=&index=1&list=
Hello again,
i made a bit of progress but i am having some troubles now.
Here is my setup for two players:
The trouble i have now, that the widget seems to loose the owning player controller, i am able to hit the touchfields with my mouse, but the buttons
wont react to any mouse input. The problem occurs as soon as i try to open a new level
Any help will be appreciated 
ah ok, it seems the player controller is still part of the About_Blank level… so i think using the level blueprint is not the right way to start from. I would like to know what they did in the twitch video before using the gameinstance
would be cool if someone point me to the big mistake i am overseeing 
still no progress… everything i try fails…
i really need help
In the twitch example, the widgets are created on the GameInstance class blueprint. The GameInstance class is persistent between level transitions and they handle their “HUD” state there. You should also make sure that if you are using different player controllers that they both have enable touch events.
Hey thanks again for the answer,
unfortunately i am not at my pc right now.
I redid some things now and it seems that it could be working that way too.
Each level i have will create a User Widget Creation for a player loading that level.
GameInstance Init -> will prepare the default when the game starts for each player.
As far as i know, every Player will have an own GameInstance.
When i play around with delays i almost get the right result, but im not sure about that workflow of delays in order to handle each gameinstance for each player.
The best result was that both Player could receive Input, but for the client that input for UI Buttons was only 1-2 seconds enabled and then gone.
However to refer to your answer, i did the creation in GameInstance as well, and i think using the enable Mouseclick for touch input should work for all testclients.
When simulating and playing with delays of different sizes and different locations i can observe the gameobject browser, that sometimes both (for 2 Player) GameInstances were created and both PlayerController were created, sometimes the load StartMenu Map only works for one player and the second stays inside About_Blank for some reason.
Ok after hours of debugging and editor crashes, im still not able to create a client standalone.
Target:
- Create 2 independant instances of the game one on Server and one for a client
- both have no connection yet
This is where it fails.
When i debug these the following happens:
- GameInstance for Local Player (PC 0) is instanced.
- when the delay is hit, the construction of PC0 is fired -> First Player Controller established.
- after that the second GameInstance is running
- when the delay is hit the game crashes and no PlayerController for the future Client is established.
Bumped my head on my desk a few times… still no progress 
Hahahha… omg, i got it all wrong…
got nothing more to say to that…
ok that wasnt the solution either, but i think if no one can tell me how to run 2 offline sessions in the editor, i will create a shortcut for that
hmmm, when i open the level somewhere else everything works as expected.
I also read some similar posts on answerhub. Dunno if they are related to my problem.
I think what i should avoid is trying to load a level on GameInstance´s init.