[Unreal Engine] - How To Create A Multiplayer Game

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video i'm going to be showing you how you can create your very first multiplayer game using unreal engine 4. we're going to be creating a listen server which allows you to both host and play the game on your own computer other people can then connect to your server using your ip address it is important to know that you will have to open ports on your router in order for other people to be able to connect to your network and server i will talk a little bit more about this later in the video to set up this project all you need is unreal engine 4. i'm using the version 4.25.3 we're going to launch the engine and create a new project in the new project category select games and click next i'm going to be using the third person template however you can use any template that you like to use after the template has been selected click next finally we're going to be using blueprints maximum quality ray tracing disabled desktop and console with no starter content you can use whatever settings that you want to use here i'm going to name the project to multiplayer game and then click create projects you can immediately try the multiplayer features built into unreal engine 4 by clicking the drop down menu besides the play button under the multiplayer options change the number of players to the total number of players that you want to spawn and the net mode to play as listen server when you now press the play button multiple windows will appear allowing you to control each of the players i only selected two players which means that one will be controlled through the viewport and the other through a separate window in order for you to be able to connect to a specific ip address we need to create an interface with two buttons one for hosting and the other one for connecting we also need an input text field where we can enter the ip address that we want to connect to we're going to right click in the content folder go to the bottom where it says user interface and select widget blueprint i'm going to name this to umg underscore interface you can name this interface to whatever you want i'm going to double click on the umg interface to open it up and i can now construct the interface i'm going to drag out two buttons and two texts into the buttons i'm then going to head on over to the input group and drag out a text box i'm going to resize the text box enter a hint text and modify the font size i'm going to resize the buttons and change the text finally i'm going to change the actual name of the buttons and the text box so that i can differentiate them i'm going to head over to the graph where i'm going to write the script that the buttons are going to execute i'm going to remove the existing nodes and then select the button connect variable in the left panel go down to the events and press unclicked i'm then going to select the editable text box ip variable and drag it out and select get editable text box ip i'm going to select the button host go down to the event section and press on clicked there are multitude of ways you can set up a way to connect and host the server unreal engine 4 has some great notes that can be found if you right click and search for session there is also an advanced session plugin that you can use which will extend the session capabilities using these nodes you can set up a server with the name limit the number of players and even set the server to only run on a local area network using the find session node players can then retrieve a list of all the available servers in our case we only want to connect to a specific ip address but if you want to create something more fancier now you know that unreal has support for it using the session nodes what we need is the open level node in the level name we can specify the level that we want the server to start i'm going to copy the name of the third person example map that you can see in the viewport and paste it into the level name i'm then going to press the down arrow and expand the hidden features and under options we want to write listen for the button connect we want to retrieve the ip address that we entered into the ip text box and then connect to that server we can easily do this by dragging the blue pin from the editable text box ip search for get text we then need to feed the text into another open level node you can't directly plug the return value from the get text into the level name because these variables are not compatible so we have to add a new node from the get text variable that is called tostring you can then plug this into the open level which will convert the string into a name finally plug the open level into the button underscore connect our interface is now complete whenever you enter an ip address and press connect you will connect to that ip address and if you press the host button the player will host a new server we now need to display the user interface to the players so that they can access the buttons back on the main screen we can press blueprints and then open level blueprint to display the interface when the player starts the level or joins the server we need an event begin play and then we hook that up to a create widget and here we want to select the class that we called umg underscore interface we then want to drag the return value from the create widget and select the add to viewport node this will be enough for our testing purposes however if you want to tidy up the interface you will want to set the input mode to ui only and enable the mouse cursor for the player when they are using the interface the project is now complete if we hit the play button our two players will spawn into the same level because they automatically connect to the same server if i press the host button a new server is created and you can see that the player is all alone on that server i will now connect the other player to the created server using my local network ip address if you are on windows you can find the ip address by opening the command prompt and typing ipconfig in our case we want the ipv4 address i'm going to copy the ipv4 address paste it into the text box and then press the connect button you can now see that both players are in the same level if you want to play your game with another person you need to package the project this can be done under file package project and then select the platform that you want to compile for the player that is going to connect your server has to use your public ip address you can find this by typing what's my ip on google secondly you need to open the ports on your router in order for someone to be able to join your server this can be done by logging into your router going into the port forward section and here you want to open the port 7777 so 7777 and now everyone should be able to connect to that server if you have any problems with hosting or connecting to another player your internet provider may have blocked you from opening the required port thank you for watching this video if you enjoyed it please make sure to give it a thumbs up and subscribe to the channel have a good day and i'll see you next time
Info
Channel: Elias Wick
Views: 113,320
Rating: undefined out of 5
Keywords: How To Create A Multiplayer Game, Unreal Engine 4 How To Create A Multiplayer Game, UE4 How To Create A Multiplayer Game, How To Create A Coop Game, Elias Wick, Game Development, Rendering, Photoshop, Autodesk, 3Ds Max, 3D Software, Modeling, Texture, Textures, Materials, Tutorial, Lesson, Animating, Create my first game, creating game, 3d artist, 3d games, 3d environment, Game developer, Unreal engine 4, UE4, Advanced, Beginner, Projects, Tricks, Tips, Learn, Unreal Engine, Unreal Engine 5, UE5
Id: 1MA9_U3XRZs
Channel Id: undefined
Length: 8min 2sec (482 seconds)
Published: Tue Oct 13 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.