Creating Pit Traps (Terrain Modifications @ Runtime)

For my game I was trying to make a pit trap in Unity. I'm okay at coding but this is the first time I'm creating a game beyond 2D and with an engine of any kind.

I've seen these two questions regarding terrain deformation. I took the code from the second link and modified it to go in the negative direction. However, it appears that unity wants to keep the terrain consistent, so I'm ending up with a conical depression rather than rectangular or cylindrical. Is there a way such to insert a cylindrical pit in my game? These need to be created upon demand as gameplaywise a player can create a pit at any arbitrary location.

Brainstorming with my friend we've thought of creating a cylindrical prefab object that translates/spawns and replaces the terrain where the player wants to place the trap, but we feel that that way seems like sort of a hack. What's the right way to get a proper trap? (Cylindrical or cubic, the implementation is not as important as the fact that you shouldn't be able to bunny hop up the side)

Thank you

I can think of some ways to do this without any terrain modification. But a lot depends on the complexity of the terrain, what type of camera you need, and how realistic it needs to look.

1) The first is to instead create a flat texture that marks the hole's position without necessarily looking like a physical deformation. (Animal Crossing does this.) Sort of an "X marks the spot". Could be a simple circle or jagged-edge polygon.

You could actually make it look a fair bit like a real hole with the proper shading, but if the terrain varies a lot it might not match perfectly. You might need differently drawn holes for differently textured terrain.

You'd splat this texture at the position of the hole. If the terrain is mostly flat this shouldn't be too hard, particularly for third-person RTS camera. If it's bumpy, you might have to mold the polygon with the texture on it to the terrain. But if the terrain is bumpy, and/or the camera can get close to the hole and/or rotate around it, then this just might not look very good.

2) Take a look at this shader on the Unify wiki.

Used for a boat, it appears like the bottom of the boat was below the surface of the water, even though the water is just a flat plane. Seems like this could be adapted to your case. Googling just now I see at least one person reporting this shader doesn't work yet for Unity3, so you might want to get involved with that discussion.

Again, you might need to do some work to splat the texture to the terrain if its very uneven.

3) A variation of method 1 that might look more realistic would be to render a 2nd camera to a texture. That camera would show the hole. The point to this would be to make the hole's viewing angle change as the camera moves around. It could be adapted from the way reflective surfaces are done in Unity, but instead of reflecting what's above the surface, it would "reflect" the image of the hole.