This is how you code an undermesh prevention

Good day everybody,

I recently developed an undermesh prevention for an upcoming Unity game in C#.
It works quite well and I thought you might use a similar technique for Conan Exiles.

  • Before object placement, make 6 raycasts (3 dimensions = 6 directions) from the center of the object ghost. We rotate the angle of the casts randomly for further security.
  • Let the raycasts ignore anything but the world-mesh. Otherwise, the ghost, the player or other building parts could block the ray.
  • Once you hit a face of the mesh get its normal information. (Make sure to only count the first face you hit)
  • If the normal information of one of the hits by the 6 rays points away from the ghost, the player is attempting an undermesh placement.
  • Instead of placing the object, output a message, saying that undermeshing is not allowed.

Have a nice day and stay healthy!

3 Likes

From the center of the object ghost? So you can’t sink a normal foundation more than halfway into the ground, with the top surface still above the ground? Or did I miss something? A diagram might help, I’m not a very visual person.

1 Like

We do it from the center and yes, this results in a max of halfway in.
But this is a minor issue because you can get the length of the ray or at least the distance from the center to the hit. You then can set a threshold under which placement is still allowed. After all, this is just a second condition to determine how deep you can push the objects in the mesh.
You could also add a new variable to the master placeable object class and give them individual threshold distances. Or you could use the size of the objects + a simple formula for an automated individualization.

1 Like

Hire this guy

I could see doing this for storage items. For foundations, I’d like to see them add logic that allows a foundation underneath a “legal” foundation, with the under foundation being destroyed when the legal foundation is destroyed. Same with ramps and a few other things, otherwise you’ll have too much weird floating architecture, or annoying gaps between stairs/ramps and something like a cave wall.

I’d also like to see this be fairly configurable from server options, or at least commands, otherwise it might make building special buildings very difficult for admins.

I say this, because there are a number of “special buildings” I have built on my server (as an admin, that are also invulnerable) that serve as hubs, and there are some very screwy things going on to make them function decently or make them look cool.

Or simply add a deathdecay layer 4-5 feet below surface map that breaks down objects and players.

Mountains and place-ables would need special care.

Surprised this isnt something that part of map creation when setting landscape.

I look back at older ES/FO titles that have a room were dead npcs go. Or a place were all objects reset to. (Fallout 3, you could go below 1st town, and find items and npcs that fell thru ground in mass. )

1 Like

I think this is what they already did (at least in some places) that caused such issues when the falling through world bug was prevalent (last month?).

Very nice thought. However do you really believe that they do not know how to do it? The same persons do not allow you to build in several places. So if they decide to stop you build any place they want they know really well how to do it. So, again nice thought, but they fixe it and they decide what to do with it :wink:. All we can do is ask and wait

Well, I guess making a building restriction in Conan Exiles currently is just placing a box volume and scaling it. That would not be very accurate and fixing every possible undermesh spot would be brain-melting tedious. Funcom is probably better in designing than coding so they probably prefer solutions through level design over programming. But that’s all just coffee cup reading, so nevermind.

1 Like

My dear friend. It seems that you are a person that really knows technology. For me all that you mention up there where a little bit Chinese :joy::joy::joy:. I really hope one day they will decide to stop players, only in pvp mode, to build undermash.

1 Like

this is a good idea but with a limited space that we have … on some server we built hub under the world to not allow it to distract from PVE or being abused in such a way. and we need every space available to use Z+ and Z - to help with expanding the world

a few reasons why this wont work it is far too resource intensive, raycasting will cost a ton of power between network and client at least and you just cant raycast the map(world mesh) and expect that to do it as the map itself is suprisingly flat and barren, most undermesh is built into rocks etc(game environment assets) because of this, so you would need constant building raycast checks on each single object whenever a player is attempting to place an object, given the kitbash nature of the world the normal information of the mesh is likely to include inconsistencies and overlapping, you could for instance be placing an undermesh foundation in a hollowspace between rocks or the outside of the mesh to a non level area where its attaching to a world object but not inside any object (the main map being a flat plane its normal is facing forever upward and normals on objects forever outward).

realistically I thought myself the best way to solve this would be a simple secondary collision smaller than the mesh which would both teleport players to the desert and do undermesh checks however this again wouldnt solve the hollow space problem and this would be extremely costly to do (as you would likely need to make a new custom collision box for every world object in the game) but the word is funcom has already designed some new anti undermesh tech so we will have to see what they come up with.

You can do the raycasting entirely on the client (as long as you don’t change anything the server doesn’t need to know it - and checking isn’t changing).
If you want it more secure, you do it entirely on the server as part of the normal building function. All you send to the server is “build”. Server checks, server sends back “isbuilt” or “isundermesh”, client again outputs to the player.
So, I don’t see, how this would affect network performance at all.

Raycasting is not resource intense if you do it “once” (meaning in this example 6 times per building part) and not constantly in a loop. If every building part would check every frame - yes then for sure it would break the game.

If you place static parts of the level, you should somehow tag/identify them as level parts. It doesn’t matter if it is a large scale terrain mesh or a cliff. The building placement method already knows, what is a part of the level, else you couldn’t add foundations to the terrain, to cliffs, statues, giant trees and so on. I guess at the moment, when you place a foundation, they are just checking if it is overlapping with a mesh of the level (or rather the collision meshes of the two, which is easier).

Yes, there may be (I think very rare) occasions, where this method fails to catch an undermeshing attempt but, for the the remaining few spots, you could just place a box volume as for camps or dungeons.

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.