Create a p2p or dedicated server

Hi everyone, I have a request today.
I try to make a network for my game, but I don’t know how to process to setup this.

there is difference between setup dedicated or “normal” server?

“normal” server is when one of the clients is a host (client acts as both server and client), host starts the game on it own computer and the rest connects to it, commonly used in LAN but can work beyond that. When host leaves games ends as host worked as server

P2P (or rether the thing that is called that way since it not always real P2P) is same as “normal”, but connectivity methods are different in the way so players can connect to eachother even behind NAT and Firewall by using varius tricks, like host connecting to client, proxying (client side or provides by some proxy server), session migration when host leaves, in other words make it fell that everything runs on dedicated where in reality everything is hosted by clients, i think to better word this, it feel that everything is run by the “cloud” ;]. It’s also managed by session server, which is more advances master server which manages connection between devices as well as do match making, some online services provide that for you. UE4 does not support P2P but it is in road map, it’s on the roadmap since long time and it untouched, so some day.

Still you can make session systems with what UE4 has and i think it is possible to make it migrate host, but i don’t think you could do that with just blueprints. IT won’t be comftible thru, 2 players behind NAT and Firewall won;t be able to connect to eachother, UE4 simply need to know diffrent connectivity methods.

dedicated server (don’t mistake with all-purpace server service) is server running sepretly from client, it simply can run alone without client and rendering, it just manages game state and host the game even when there no players. As it usally runs on server machine (but it can run anywhere on any machine) it’s not behind NAT or firewall, so anyone will be able to it. It’s best quality but it a lot more expensive, usally game devlopers relese dedicated server version (or client can turn on dedicated server mode, UE4 can do that by default, you would need to built “Client” build to prevent that) so users can host there servers, manage them… and pay for them :stuck_out_tongue: So server cost won’t be devloper issue.

Session management can be done on dedicated servers too, developer host group of dedicated servers and session server simply connect all client to currently empty server, prime example of this method is Rocket League, you can even see cryptic server names being display before game starts ;]

As long as you set up replication in you game right, your game can do both (except P2P for now)

so for make a “normal server”, how to process? We need special bp for make a connexion?

You start the game with ?listen url

From blueprint you can use open console command also with ?listen

I’m not sure but maybe you can do this with session nodes too, they will work in null onlinesubsystem too

I make this but don’t work, Do you have an idea?

http://puu.sh/l5vp9/f6bc165ce4.png

I’m very sorry, I’m not good in english, I don’t unterstand what you try to say

It executes console commands not system command line :stuck_out_tongue: also i said in console it is “open” command anf you type ip or map, so for example “open MapName?listen”

Ok now I sucess to create a server, but I have a little problem, my player Server work fine, but my client don’t be render, is a camera in air ans my 3D widget doesn’t detect. I think that replication work.

That means you 2nd player is ADefaultPawn, which means you didn’t pick default pawn. Or manually spawn some pawn for 2nd player and make his PlayerController to possess it

I think that is good, I create a gameMode with my own pawn

http://puu.sh/ldOA3/86a591baab.jpg

Try setting it in Project Settings, also place PlayerStart

Don’t work too… I don’t know why

http://puu.sh/leaTx/98c0dc453a.png

http://puu.sh/leb0i/475f39aa75.jpg

You have any spawn code?

How, is that, I think that was automatically added… so I try to find how to process and I comme back if this don’t work

Thats why i’m asking if you maybe write your own code for that, as you cna od that :stuck_out_tongue: Then i dont know whats wrong, if you pick default pawn defualt spawn system should use this pawn exclusivly. You might try override GameMode functions which selects Pawn which is “GetDefaultPawnClassForController”. Place to PlayerStarts. Maybe it indeed replication problem, but it kind of not make sense as GameMode class runs exlusivly on server and it spawn objects in server state which is replicated to clients

Hmm ok try default GameMode class and set default pawn (and other classes if you need) in world settings place 2 playerstarts and see what will happen

I have already change the default pawn by my player bp, il the gamemobe bp u make this:

http://puu.sh/ljbTG/49e83fb84e.png

now when my client was connected to the server, he was not see by the server but is in the spawn position, but he can’t move (like a crash) and I must press echap for quit playing mode

With the default GameMode/Pawn, client can connect to server but I think that is not replicated because is a free camera (no gravity)

you set the pawn?

I think:
with my custom GameMode (client crash):

http://puu.sh/luxsj/65ae5f4c83.png

with default gamemode (client don’t crash but no replicated):

http://puu.sh/luxu8/824ce6645f.png