Data architecture: How to update actors everywhere, on an in-game-daily basis?

I’m not even close to being skilled enough to implement the solution to this, whatever it may be; but this question is bugging me all the same. Here goes…

I want to track the passage of in-game time – which will not be tied to the passage of time in our world. Time will mainly pass when the player character chooses to do something, and we cut to “X hours later, you’re done with the activity”; it’ll also pass when we’re moving on the world map.

When an in-game day ends, I want to send out a daily update to every character, faction, and location in the game. This will track things like wounds healing over time, moods returning to normal after big successes or failures, factions making decisions about what they want to do next, and even the growth of crops, the beginning and end of the harvest season, the progress of the spring thaw, etc.

Together with this, I want to have multiple maps. There’s the world map, of course; but there are also zoomed-in location maps, and the player might spend weeks or months on a single zoomed-in map, before eventually returning to the overworld.

During these zoomed-in periods, I need to keep the clock ticking, allowing the rest of the world to go on doing its own thing (up to and including a hostile faction sending troops or an assassin after you, if they’re confident about where you are). Whether an actor is present on the same zoomed-in map as the PC or not, they still need to get daily updates.

When I was trying to write games in C++ without an engine, my solution to this problem was to store everything that needed daily updates in dedicated monitor classes; I had a Factions Monitor, a Characters Monitor, a Locations Monitor, and so on. When I wanted to reference an object that lived in a monitor, I’d save its monitor key; I could’ve used pointers for this, but I wasn’t confident that I could’ve kept my code bug-free, and using keys made everything easier to serialize (which I was also doing by hand).

I always felt a little guilty about this solution. Singletons have a reputation as an anti-pattern, and here I was storing everything in the game in singletons…

Facing this problem in Unreal, what tools are available to me? What approach should I take? Are there any tutorials on this?

Any advice or thoughts would be appreciated – even advice on which keywords to use if I want to learn more about this question. “Time,” “daily,” and “persistent” tend to refer to other things!

Singletons being an anti-pattern is arguable, I’m sure. Hell, they are first class citizens around here – Programming Subsystems | Unreal Engine Documentation

My current project, had it started when subsystems were available, I’m sure would have at least several of them. Instead, it has more standard Unreal singletons (like custom GameMode and several other unreal classes that are used as singletons)

You definitely need something as an arbiter of all of these rules. I’d build a Subsystem to handle it.

1 Like

@eblade, this looks really good! Thank you very much!

It sounds like my existing system can translate 1:1 into Unreal. Factions, characters, locations, etc. can live in a child class of GameEngine; that class can implement the data architecture I’m used to. (Thanks for the reassurance that singletons might not be so bad, too!)

Then, in scenes and the like, the actors we spawn can be pointed to a Character or what-have-you that lives in GameEngine. Events with the actor are pass-through, and the actors themselves won’t create any sole-source-of-truth worries…

Again, thank you! I’ll be sure to hang on to this reply!

one of the Subsystem classes not GameEngine … :slight_smile: