How did Worms make craters in terrain on impact?

Hi,

Can i manipulate terrain height and create an impact crater?

(and like in worms it needs to work with physics)

Thank you in advance!
Naor

Well Worms had a texture map that it just erased pixels from, and its physics engine was written to collide with texture maps. Unless you’re up for writing your own physics engine, then “how worms did it” won’t be the best guide, so let’s figure out a close analog in Unity.

First question to ask here is: 2D or 3D?

Second question: If in 3D, do you need it to support overhangs, or not?

3d

overhangs?

hoo overhang!

i will start with the most simple way right now

So, by default, Unity’s Terrain doesn’t support overhangs. That is, if you dig a hole downward and then go left, you can’t do that. More relevantly, if you blow a hole in the side of a cliff, that’s not supported either - most likely, all the terrain above the hole would simply vanish. (I think Unity has added support for terrain “cutouts”, but that’s not a sufficient solution for destructible terrain.) If you want something Worms-style, you want overhang support, but if it’s a more specific need where you might not be blowing holes in cliffs, then you may be able to use Unity Terrain for it.

If you need to support overhangs, you’ll need to go third-party; more specifically, you’ll need a voxel terrain engine. There are several different options depending on your exact needs. Some are really basic, but open source, some cost money but produce really nice looking results, it’s all up to you. Good news is that voxel terrain almost always will support being destroyed so you sort of get that functionality “for free”.

First of all thank you for your time and effort into answering me.

I would like to know to go with no overhangs, then i will learn the more complex methods.

so where do you think i should start?

I’d probably make a black and white heightmap shaped like a crater, and when you have an explosion you subtract that heightmap from your terrain heightmap.

1 Like

If you take a look at my makegeo project it has a realtime terrain deformer hooked up to a cheesy FPS where you shoot bombs/grenades and pockmark the terrain.

The demo scene is under TerrainStuff and I think it’s called TerrainDamager. Just sync the entire project.

MakeGeo is presently hosted at these locations:

https://bitbucket.org/kurtdekker/makegeo

There’s tons of notes / comments in the code. It’s a bit fiddly to get right.

1 Like