Download

Chunk Based Terrain Rendering - What to do with enemies and objects?

So, this is more of a best practice question, as I’m figuring out how to deal with this.

So, I have a level prototype that spawns a very large procedural world. It does this in chunks within a certain distance of the player.

My question is this: what do I do with enemies or items on the map when the ground disappears out from under them?

Do I just hide them, and disable physics on them? After you’ve traversed a lot of the world, wouldn’t that be wasteful to have that many actors floating around just hidden? If I destroy them, I imagine I still have to store their last known state so I can respawn them in the same location they were last at if the chunk they were on gets rebuilt.

Is there a particularly elegant solution or thought process to dealing with this?

Cool. Persistence sounds like my boat too. So, I’ve already got structs that define the characteristics of each actor. I’ll just create a wrapper manager that holds the structs, and relates them to the chunk they belonged too (probably with a TMap). Then when the chunk is re-created, those actors are spawned from the info in the struct.

What exactly did you mean by “As long as you don’t use Tick() for keeping track of things”? I’m definitely using Tick() to determine when to spawn chunks. How else would you determine when the player is in range of a chunk needing to be spawned?