Carve holes into terrain at runtime?

Hi,
I’m trying to create a 2D game where players dig through terrain, creating tunnels to travel through. Remember “Tunneler”?

Currently I’m trying an orthogonal projection of a terrain mesh. Carving holes in editor through Sculpt->Visibility seems to do exactly what I’m looking for, modifying both visilibity and collision model…but is there any way to do it at runtime? If not, can you advise me a better way to do it? The game is strictly 2D so we can cut corners. I was also thinking about drawing directly into the terrain texture but the collision mesh still needs to be dealt with. Is there a way?

Thanks!

Note: no need for precomputed lightning.

Hi Deirh!

There’s no straight answer for your question, since there’s too much of workarounds and fakes and it’s only matter of your choice of what is better for you. The topic is pretty much complex, since such game concepts are very unique and require unique instruments for their implementation. Just for the record - landscape is not the best one. It seems to fit, but it is not so - digging tunnels on the screen is not an actual task in this case, but a gameplay mechanic with inputs, score mechanics, movement logic, etc.

Try researching this topics:

  1. Landscape Visibility Mask:
    Landscape Material Layer Blending in Unreal Engine | Unreal Engine 5.2 Documentation
  2. Try decomposing the task and divide your game field by the grid. That way you will have movement logic and graphic representation separated. Graphic part will not stop you from getting the player to actually dig the game field to expand it.
  3. You will definitely need to have your own movement mechanic, that is not based on traditional collision (since this will need to be updated in realtime), but will stick, for example to a 2048x2048 realtime generated texture to know where could player go and where not.
  4. In that case graphic representation of digging is just a post-process of your gameplay mechanic work.

Hope that will help you in your research!

Thank you very much for the detailed answer. Unfortunately I’m getting a 404 on the link though.

So basically I’ll have to go with my own simple physics/collision handling as there is no way to integrate custom raycast responses with UE’s physics engine, right? No problem there, that’s how I started implementing in Silverlight and Unity anyway, with a per-pixel terrain state, drawing any changes into a texture that is then projected onto flat terrain squares. Since the link is down for me, can I just quickly ask if there is any performance benefit to using UE4 landscape object for that as opposed to generating terrain tiles of a reasonable rectangular size, each utilizing a small texture that will be rendered into as opposed to using just one big texture for the entire terrain (in case rendering to large texture performance being dependent only on the size rendered, not size of the surface - is there an equivalent of DX RenderToSurface and then utilizing it as a texture)?

Thanks for you help!

Hi!

I’ve corrected the link in the previous post.

Talking about collision and your specific game task - the easiest way to do this is not checking actual world around pawn by line traces, but rather use your game field texture to check collisions (I think this is really the best implementation for your concept). This is pretty custom model of collision, but it should work much better for you.

Talking about RenderToSurface analog - yeah this is called Canvas Render To Target 2D. It draws whatever your game will produce as a data. Please take a look at this documents and threads:

Also you could find this helpful for your procedural world:

Hope that will help!

Thank you very much, great resources!

Have you got any success on this? I searching for a same solution.