How to edit terrain hight map during runtime?

I’m trying to make a crater on a terrain after an explosion. I dont know how to go about this. any suggestion?

You need to do a few steps:

  1. figure out the terrain heightmap location from your explosion’s world position

  2. deform the terrain, including any splatmap changes you want

  3. write it back to the terrain so Unity can use it

Step 1 is the trickiest, however there are plenty of web examples of converting from world space to find a spot on the terrain. In fact, my makegeo project has examples that can make this computation, such as in the TerrainRampMaker example.

MakeGeo is presently hosted at these locations:

https://bitbucket.org/kurtdekker/makegeo

1 Like

I wanted to see this work too so I made a cheap-and-cheerful demo of terrain deformation from a thrown grenade.

The code is all available in my open-source MakeGeo project. Search for the TerrainDamager scene. It doesn’t do splatmaps yet but maybe soonish.

MakeGeo is presently hosted at these locations:

https://bitbucket.org/kurtdekker/makegeo

2 Likes

Thanks!

1 Like