Handling Net Cull Distance - Alternative Solution Needed (My brain hurts)

So, some quick background. I am using the Runtime Mesh Component (plugin similar to UE4’s Procedural Mesh Component) to build a landscape mesh from vertices. These vertices are defined using coordinates relative to the actor’s location.

What I have been doing is dynamically spawning actors then having that actor spawn a Runtime Mesh Component with varying elevations to simulate land.

(pardon the shoddy MSPaint)

These actors are spawned in a grid, side by side and the Mesh Component’s vertices are aligned to create a seamless landscape. However, the world location of every land actor has a z value of 0 regardless of the mesh component’s elevation.

This is fine normally. Except this is in a multiplayer environment and these land actors are replicated.

These land actors have a Net Cull Radius (indicated with a red circle). If a player is within an actor’s Net Cull Radius, that actor will be replicated. This works fine at low mesh elevations (left side). However, as the player climbs higher and higher, they eventually go outside this Net Cull Radius. The end result is the land disappears under the player … the player falls until they are within the Net Cull Radius again then they are placed back up on the mesh. And this repeats. It’s awful.

So … potential solutions:

**1. Increase the Net Cull Radius on the land actors: **I don’t like this too much. It’s the most straightforward solution but has several issues. Firstly, I don’t know what the furthest distance the player will be from the actor (highest Z of the mesh). Secondly, at lower elevations, this will cause many more land actors to be replicated than there needs to be.

**2. Adjust the actor’s Z to correspond better with the mesh Z’s: **So the most logical way I can think to do this would be to take the average Z’s across the mesh component and use it as the actor’s location. That should be enough as long as I restrict the steepness to now allow something ridiculously extreme. The problem here is that I determine the vertices data for the meshes first. Then I spawn the land actor, passing it that data. But if I take the average Z’s across the vertices and spawn the actor at that Z, it shifts all the vertices by that amount (since the coordinates are relative). But … I can’t figure out what the actor’s location should be prior to determining the vectors because I need to know what they are first. It’s a catch 22. The only way I can see to go about this is to calculate the vectors, determine the average Z (to spawn the actor at) then go back and subtract that value from all the vectors. It’s super clunky and I don’t want to do it.

**3. Some other way of handling Net Cull Distance I’m not aware of?: **???

My IDEAL solution would be to somehow override the Net Cull Distance functionality to say “If the player is X distance away from this component”, not the actor itself. But I have no idea how I would go about that.


I would look into making a custom Replication Graph.
That way you can add a special case for your custom actors.
i.e. Check their distance in a 2d plane instead of 3d, thus ignoring the Z origin.

Hmm, that’s interesting - I had no idea this existed. Thank you, I’ll read up on this - I have a feeling it will take me a while to figure it out.

Well, many months later I have finally attempted this. I watched this youtube video, a lot of which I didn’t understand but I just copied it as he went. By the end … I’m not sure I’m in any better place than I was when I started. I really didn’t wanna mess with any of this stuff and I think what I have here is overkill. I don’t see any way to customize the way the distance is checked. Do you have any experience with this Kris? Or anyone else?

Not as yet, no.
It is one of those things I keep meaning to dive into when I have the time… yet I keep lacking the time :slight_smile:
I’m sure it will eventually become something I have to for the sake of the game, as AI numbers increase or people continue to run servers with more then the intended player count.