Can't connect two players to the same room.

Hello, I am trying to learn how replication works in Unreal Engine, Here’s i could have two players in the editor:

But When i build the game and run it twice (either from the same PC or from different PCs, each of them exist in a saperate room).

Sorry if this is a noobie questions, but i am still new to Unreal Engine.

Watch and read this, as it will answer all of those questions: How To Create A Multiplayer Game In 8 Minutes | Community tutorial

In short, when you start the game in Unreal Engine and setup to spawn 2 clients they will spawn in the same world. When you start two separate instances of the game, as you did; they spawn in their own world. To fix this you will need to connect to the server on each of these clients. Either player one connect to player two, vice versa.

If you want to setup a system so that they spawn into the same world you would have to do some trickery and setup some code on Begin Play. You can set it so that the first player tries to connect to an IP address. If it fails it hosts it’s own server. When the next client opens the game it will automatically connect to the first client. (Keep in mind that this may be a bad solution for scaling for more players).

1 Like

Thanks for the reply, but what if i want to make that without having to deal with low level details like IPs and ports, What is the popular method in UE that provides an interface to deal with that?

It all comes down to IP addresses in the end. For testing and local hosting it’s a great method for connecting and hosting a server.

If you don’t want to use that I suggest implementing a Online-Sub-System. These add additional features when hosting on a specific platform. Epic and Steam has one if I am not mistaken. I suggest looking at this thread for a deeper dive into this: Advanced Sessions Plugin

1 Like

Okay, Thanks A lot.