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.
Thoughts?