Help processing the world outside of the rendered scene in the background

Godot Version

4.2.1

Question

I am looking for some advice / guidance. In a game I’m making with my wife, we need the townspeople to be able to do things autonomously outside of the scene that is currently active. I’m using GDScript, btw, not C#.

Think about this like Stardew Valley a bit, NPCs are on a set schedule, yes, but they are free to autonomously walk around even when the player is not in the same scene.

Very simply, I guess you could call this game my wife and I are making a 2D hospital sim. I need the game to be able to determine what towns person gets sick and then they need to autonomously navigate from their house to the hospital, possibly interacting with things on the way, even when the player is only in the operatory.

Right now, I have my game set up with a scene manager. When the player walks through one door, the scene manager instantiates the new scene from the resource path, adds it as a child, then queue frees the old scene. I’m sure I probably need to rethink my system a bit, but how do I allow things to happen in the world outside of the rendered scene, processing in the background? Are there any suggestions, tutorials, or system or algorithm resources you can point me to to help me figure out how to set this up?

I need it to work first and foremost, obviously, but if done wrong I can see this becoming incredibly inefficient and bogging the game down. So I really need help.

1 Like

so when entering the hospital/house, you shouldnt queue free the towns scene and its people, if you want to keep them busy and realtime moving while you are inside hospital/house, what you can do is to set them invisible during you are inside the house

1 Like

It’s a question I have wondered about. Do you manually simulate everything in code while it’s off-screen, or do you leave your actual geometry and the Game Engine that to do the simulating?

I imagine the solution is somewhere in the middle, depending on how slow it all gets.

1 Like

@zdrmlpzdrmlp This is kinda what I was thinking. Here’s a question about this approach, and this is going to sound ignorant, but how about removing it as a child but not queue-freeing? If the scene is not drawn but not altogether deleted, will the people still be able to move about?

if moving by position, i tested with tween and process
tween position with tween_property will be triggered after readded child and it went flying to the position designated to be, while process will keep processing in the background until readded child
you will need to test it yourself especially with your attached script, if any of them work too

2 Likes

Thank you!