I’m working on a game that relies on the map being split into multiple chunks.
By this, I mean the Chunks are stored in Replicated Storage and cloned when needed. I. E. Player enters ((Teleport to)) a town; town is cloned and placed into the Players client.
I’m wondering as to how I can make this work with enemies // Hostiles?
Due to the environment being rendered locally; enemies will need to be visible for all clients and react the same so that a sense of normality is maintained. Otherwise Players will just be shown to fight thin air.
Does anybody have any suggestions as to how I could do this?
I have a theory that I’ve not been able to test yet:
Using Magnitude, a Server Script detects if a Player is within the proximity of a spawner location - If so, the designated Hostile is spawned & the Networkowner is set to the nearest Player - This is so the Server hostile can still react to the client environment.
As for spawning - The spawned hostile will be placed into a specific folder for the Chunk; the folder is then either shown or hidden on the client depending on whether or not the Player is actually within that Chunk.
Bc the Chunk / Map pieces are generated client-side - The NPC won’t necessarily respond to the terrain and environment due to it technically not being there and will result in the Hostile falling.
Load the chunk on the server as the enemies are server-sided anyway (other players will be able to see random chunk though)
Load an invisible collider of the chunk on the server when necessary (you can disable CastShadow for performance)
I am not sure if there is a fancy solution to this problem. Client-sided terrain is great for performance (as computational complexity does not increase with amount of players), but does have its own limitations.