Keeping character in game for persistent world

Essential idea is that characters of currently logged-out players are supposed to wander around and later on even do some advanced tasks through AI. It should give immersion of a living world instead of characters disappearing. I am still at very beginning of discovering UE capabilities and I am wondering what would be easiest approach to do that.

My main concern is probably how to actually identify same player. Obviously there will be some sort of authentization, which I have to figure out also. I am not entirely sure how I would actually say that player with this “account” should possess that particular Character he left there before or get eventually get a fresh one that will be randomly spawned on one of hand picked location.

What you are wanting to do is fairly complex, but I can tell you how I do it. First, I created a JSON web service using C# .NET that keeps track of my world at all times in a SQL database. I then use the free VaREST plugin for UE4 to connect to the JSON web service to get information about my world and my characters. Since UE4 does not have large world multiplayer support, I run multiple maps with 1 per port. So here is an example setup: I run the UE4 login server on port 7777, I run my first map (let’s say a large city) on port 7778, and then I can run additional maps of other areas outside the city on other ports. I then run multiple copies of UE4 in server mode for each of the ports. When the player starts my game it connects them to the login server, when they enter their username and password, it connects to my JSON web service to get the character data for that players account. Four of the values it pulls are Port, X, Y, and Z. This then tells the login server what port/map to server transfer them to and what X, Y, Z location to spawn them at. The servers are always running so, everything (like the day/night cycle) keeps running whether players are logged in or not. To have the player continue to do things after they log out, you have to options. The easiest is to hand wave what they do. So you would calculate the amount of time they are logged out and then have a SQL job run to update what they would have done in the database while they were gone. However, if you want the player to actually be able to interact with other players when they are logged out, then you will need to have an AI controller take over their character when they log out. Keep in mind this will probably not scale well, but it works okay for me because my game only has 4 to 6 players maximum.

If you have any specific questions let me know. This system took 6 months to build and I have been a professional programmer for the last 20 years.

first of all i have no idea of network stuff.

how many players should be affected by this mechanics? if its like below 100 you could do it like:

  • a player has a specific ID , lets say 45,

on joining the session it would check an array which includes all offline Actors, looping through that array and look for the index of the id , if it is found i get position and updated stats while you were offline and possess again . you remove it from the offlineactor array and if you fed up with playing and dc, you add it in again and it runs its ai thing again .

this is just brainstorming , sry if i am totally wrong :slight_smile:

@Erytriel: That looks really great, thank you !

Ok, REST service makes total sense although some security is in question as people shouldn’t generally able to connect to that service and ask for a location of any other player.

Yes, I want players to interact with those that are offline. We would even like to have AI that takes care of combat when player is attacked while offline :slight_smile:

Splitting to multiple servers sounds like a must for sure. That’s something we haven’t figured out yet in our current prototype written just in Javascript. You are saying 6 months, huh… That’s gonna be tough nut to crack.

Thank you very much, I will surely have more specific question once I get to actually solve this. This was merely a preparation for upcoming work.