Tunnel into terrain

is it possible to cut into the terrain for a tunnel? And if it is: How to disable colliding just for this hole in the tunnel, so I can “enter” the tunnel?
Thank you.

Depends on how you make the terrain.

E.g. if you are talking about TCastleTerrain (Castle Game Engine: CastleTerrain: Class TCastleTerrain) then no. I’m not familiar with the details, but AFAIK this terrain is built based on a “heightmap” which has only one value per a coordinate pair on the plane i.e. you can’t have a “hole” that will have 3 values - hole start, hole end, and upper layer.

To my knowledge the most regular approach to make “modifiable” terrain is by using voxels. E.g. like the one used in Minecraft or Subnautica. They either represent the world as a large number of relatively primitive shapes, or as a mesh that gets rebuilt every time the user changes it. Yes, this is possible to make in Castle Game Engine, some time ago I’ve made a Minecraft-like renderer and it was relatively easy: Castle Craft - Minecraft mechanics using Castle Game Engine - YouTube. The actual terrain can be made smoother.

Hi eugeneloza
thank you for your help.
Yes I’m trying to work with TCastleTerrain. I had my own engine and was able to have tunnels in it. So I wanted to get it with CasteGameEngine too.
Thanks again

Underneath TCastleTerrain is a mesh (set of quads or triangles). TCastleTerrain.UpdateGeometry builds this mesh, you can look at implementation. You can even access this mesh if you know what you’re doing :slight_smile: Like

InternalTerrainScene := MyTerrain[0] as TCastleScene;

and then access nodes inside InternalTerrainScene.RootNode. You can copy, change them.

So if you want to do tunnels by doing CSG (constructive solid geometry) algorithms at runtime you can. Admittedly this is quite involved (esp. if you want to do this at run-time and be fast enough) but I understand you already have it implemented in own engine, then it should be easy :slight_smile:

Thank you michalis. I’ll look into it.