03 | Setup a Local Dedicated Server in Unreal Engine

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
okay so in this video we're going to build our dedicated server locally and test that we're going to make a few changes in the unreal engine game so that we can test the client and server network interaction just make sure everything is correct and working so what i'm going to do is open up the visual studio solution file and there's already a build target for the editor within the project by default and we can use that as a base to sort of create a new server build target so as this loads up you'll see on the right hand side we have a vs editor target dot cs file we're going to create a new one and we're going to use this as the basis so let's just right click and add a new item in the location we want to basically change that to be unreal and then the source folder we'll select that folder and then add a new file and this is going to be called vs server dot target dot cs we'll add that into our project it's a nice empty file and we can copy and paste the editor target into here and make a few changes so we're going to first rename the class to be vs to server target and we'll also make sure that we have our constructor renamed as well for the type we're going to change it from editor to server and we also then need to add on the class an attribute the attribute we need for this is going to be supported platforms and then in parentheses unreal platform class dot server and that's basically it that's our build target setup so if we save that and we close this down we can then open up unreal and basically make sure that we can then build our dedicated server as expected so in unreal engine we should now find that if we go to package project and we basically have a build target now for vs server and in the package project itself build configuration we're going to leave as development and we're going to build it for win64 just to test it and what we're going to do is basically create a new folder called releases and within here we'll select the folder and basically that will start packaging the dedicated server so i'm going to leave that doing that just for a minute and then i'll jump back into the video once it's complete okay that's for now finished building so if we go into our folder we've got a releases folder here and windows server what i'm going to do is create a shortcut so we'll create a quick shortcut here and right click on that and click properties on the end of the target here we're going to put dash log and hit apply and then we can double click that just to see whether it actually starts up and here is our unreal server built for windows so the next thing we want to do is just test that you know we can connect to uh this server uh from that from our game so what i'm going to do here is just go up to the play settings and ensure my net mode is played on standalone and the number of players is one and the other thing i'm going to do for now actually is in our current map we've got here we've actually got a um character sort of in the world so i'm just going to delete that for now because it can get a bit confusing and it's not what we need because when we connect to a game um it will actually spawn us at our power player start location which is just here our network player start so if i hit play you'll notice that i'm in our world but we're in our world locally just right now and what we want to do is actually connect to our server here so what i'm going to do is i'm just going to hit play and we're going to be in our local client world and what i'm going to do next is then open 127.0.0.1 also known as localhost we'll hit that and then you'll notice that something strange happens in the sense that ultimately our screen's gone blank but if you notice within our server window everything has worked correctly we've connected to the server from our local client and what's actually going on here is there is a project settings that allows you to specify what map gets loaded when you connect to the server so if we go to edit project settings and we search for server map you'll notice it's actually loading the server default map which is called entry which is actually part of the unreal engine itself to make things a bit clearer on what's going on what i think we should probably do is create a client map and a server map to do this i'm going to create a new folder in content called vs and another folder within here called maps and i'm going to basically copy the map from here and paste it in our new folder and i'm going to rename this to client map and then i'm going to duplicate it once more and call this server we'll open up server map and what we'll do is just change this text ion here to server map just to make it clear and we'll do the same for the client map we'll change this to client map and if we go back to our project settings in unreal and we change that server map to be server map and then we also then need to change if i search for maps the game default map to be client map and our editor style we may as well change to client map as well just to keep things tidy so if i save that and hit play we're now in our client map which is all good what we are going to need to do though is obviously rebuild our server and the other thing is that when you build the server you actually have to tell unreal what maps to include so if we go back to the project settings you'll notice that in packaging down here you need to add in the maps that get part get placed in part of the package so i'm going to add in our maps which is basically game unreal content versus maps and we're going to add the clamp map and we're going to add another one the server map and we're going to save so just before we repackage the server what we do need to do is actually close down the running server else it won't be able to overwrite the files because they'll be in use so if we just go to our server and we just close that down now we're ready to start repackaging the server so let's go to file and then go to package project you can see our build target's still vs server our build configuration is still development we can hit win64 select the folder and then it will repackage the project for windows once again with our new settings including the maps that we need just so that we can test to make sure that the entry map gets loaded when we connect the client to it so packaging is now completed let's start the game locally and just ultimately start the server once again so if i go to the game in unreal guide unreal releases windows server we've still got our shortcut server starts up and now using the console tilde key once again we can open 127.0.0.1 and now you can see if we look at the ground we're now connected into the server on the right map called server map okay so let's test what happens when we have multiple clients connect to the server to do this we're going to go to play and we're going to just change the net mode to play standalone and number of players we're going to set to 2 and then basically if we hit play we're going to get an editor client and we're also going to get a window for another client on the right hand side much as we've done before we can now use the tilde key to bring up the console and open up to connect to our server we're now in the server map on the right hand side and on the editor we'll do the same thing and you'll also see that we're now connected you can now see the gun of the other player floating in space and just to prove that the movement works as you can see this uh actor is being replicated and the other clients can see the movement so with that said we'll go into more detail on sort of adding uh replication uh so that basically we have player models and other movement as well as as you can see projectiles not also replicating at the moment but for now this gets us to a place where we have our server connected and tested with multiple clients in the next video we're going to go through taking a skeleton dedicated server and turning it into a docker image to allow us to then deploy it into eventually what will be a hosted kubernetes environment so stay tuned for those videos
Info
Channel: trashart
Views: 2,305
Rating: undefined out of 5
Keywords: unreal engine, unreal engine 4, dedicated server, unreal, server, unreal engine how to setup a server, unreal engine 4 tutorial, unreal engine dedicated server, unreal engine 4 dedicated server, unreal engine local server, dedicated, unreal engine tutorial, unreal engine tutorials, how to setup steam in unreal engine 4, unreal engine server
Id: DScZxKNLMTE
Channel Id: undefined
Length: 9min 41sec (581 seconds)
Published: Tue May 04 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.