Reconnecting player to the ongoing match in case of network errors

Hello all,

I am fairly new to unreal engine and game dev in general. I am trying to create a multiplayer game in unreal engine 5.2 majorly with blueprints and a little bit cpp here and there. I am using a dedicated server which is hosting the game map and all my players connect to that map from their respective entry maps (menu screen).

I was hoping for some support when it comes to creating reconnection in case of network failures.

My game instance is written in cpp and has a child blueprint class as well. I am able to add a widget for errors using “networkerror” and “travelerror” nodes in blueprints when i try to simulate network errors. The problem is my player is thrown out of the server map to the entry map when there is a connection error.

I can live with that, considering there is a way for me to find that game again.

Any and all help is appreciated.

Thanks.

No idea on how to do this, and you seem to be well on your way of fixing it yourself. What I would do is to set a boolean variable in the game instance to true when you are being thrown out of the server. The variable is checked every time you enter the main menu. If it’s true; showcase the widget that asks the player if they want to rejoin the server.

1 Like

Thanks for replying @EliasWick ,

I actually went through -

This looks really difficult as it includes a lot of CPP but seems like the right way. I’ve read this whole page a few times and learnt a lot of things.

I’ll have to change a lot of my existing project from blueprints to CPP in order to even get started with implementing this solution.

I’ll post an update if this works for me.

In the meantime can you or anyone else give it a reading and tell me if this is the right way ?

You don’t need CPP to have a custom GameInstance child class and store variables in it.

You might need CPP to access the LastTravelURL or execute the reconnect console command though. I’m not sure if console commands are still allowed in Shipping builds by default.

1 Like

thanks for your input @Chatouille,

I want the players to return to the location where they got disconnected from and have all their respective items, buffs, debuffs etc.

I’ll try saving everything to the gameinstance and try to apply everything back once they are in the server map.

Sounds like multiple tasks at once, or maybe I misunderstood the question.

One task is to handle user experience when he disconnects - which seemed to be the topic here. Use NetworkError and TravelError to detect error. Store the error info in user’s GameInstance. Once user has reloaded main menu, check if there was an error and display a popup message with option to reconnect.

Second task is to handle the server side - when user disconnects, you need to keep his data around in case he reconnects. And if he reconnects, restore his data. You probably don’t need to use GameInstance for that, because the server World doesn’t change. When the user is disconnected from server, only his PlayerController, PlayerState, and Pawn are destroyed. The rest of the world remains. The traditional way to handle this is described in the link you posted above. You pretty much only need to override CopyProperties and OverrideWith, which can be overriden in Blueprint. Be wary of the pitfall though, if you need to store player location or other Character properties you need to retrieve them earlier as they won’t be available in CopyProperties (pawn already destroyed, if I’m reading this right).

1 Like

Absolutely @Chatouille , This is exactly what i want to achieve.

I’m thinking about trying this in a seperate empty project first because changing my existing one will take a lot of time and will certainly introduce a lot of errors.

Thankyou,

will update soon.

Hey @GDab99 just wanted to see how it went and if you made it work how did you do it?