# Implementing destructible terrain, deformable ground, or craters for an artillery game (think scorched earth!)

 0 Hi, I'm fairly new to Unity3d and was wondering how to go about implementing a boolean operation on a mesh equal to the radius of an explosion, or any equivalent effect to achieve a hole in the ground. This is an important element within artillery games. I have a feeling it will be non-trivial, but any help or a point in the right direction would be greatly appreciated. I am using an imported mesh, but I can switch to terrain if it would be easier to implement. The relevant questions I found suggested moving each vertex within the explosion radius outward, but I'm lost on how to do this. I found http://unity3d.com/support/documentation/ScriptReference/Mesh.html , which is a good starting point, but I need a push in the right direction from here! more ▼ asked Sep 28 '10 at 07:06 PM nathaniel 27 ● 3 ● 3 ● 7 SisterKy 2.4k ● 33 ● 41 ● 59 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

 0 These features of Unity have very little documentation. It took me allot of digging around and experimenting to make a practical deformable terrain. The concept is that Unity terrain stores Height data in a 2 dimensional array [x,y] the height is a float from 0.0 to 1.0 and it can be changed at runtime. To give craters a round concave look we use a texture with an alpha map. We then convert the pixel data from the alpha map into a float ranging from 0.0 to 1.0 depending on how dark the pixel is. Then all that is left is to subtract the crater Height Data from the Terrain Height Data at the impact Vector3 position.For the textures the process is very similar but it differs in the following way: For every texture you have on your terrain (In this case 2 textures: Grass and Dirt) you must adjust it's alpha value, for example: To get dirt we must make: Grass alpha = 0.0 Dirt alpha = 1.0 to blend grass and dirt we must make: Grass alpha = 0.5 Dirt alpha = 0.5You can find my implementation here: http://www.youtube.com/watch?v=2W3Vm1_QGf0 more ▼ answered Mar 28 '12 at 08:48 PM add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

By Email:

Topics:

x1464
x374
x38
x32
x15

asked: Sep 28 '10 at 07:06 PM

Seen: 3640 times

Last Updated: Mar 28 '12 at 08:48 PM