Deforming terrain

Hi!

I would like to have a terrain editing feature in my game that allows users to deform the terrain in a similar way to Unity’s terrain editor. I have read several threads, none of which detail exactly how to achieve this. all I know is to use the classes GetHeight and SetHeight, and something to do with raycasting.

The idea is to raise terrain at the mouse position with Mouse1 and lower with Mouse2.
Any help is much appreciated.

Thanks,
Shade.

Ok, I now know that I need to “raycast the terrain”, whatever that means :stuck_out_tongue: Ideally, I would like to:
-get the position of a mouse click on the terrain
-use SetHeights to raise/lower an area around the mouse click

Welcome to the forums.

Your not the first person to ask the question… And there are many threads which do detail this.

I have posted things about this though. :wink:
http://forum.unity3d.com/threads/104491-Deform-Terrian?p=701768&viewfull=1#post701768

You will also need to know how to get a raycast from the mouse point to the terrain.
http://forum.unity3d.com/threads/98871-building-on-a-hill?p=648192&viewfull=1#post648192

And yes, I have done something similar.
http://forum.unity3d.com/threads/101165-Canyon-Space-Runner?highlight=terrain

Unity’s terrain editor also makes use of the projector to make the visible circle, but I do not have any code that I built that does such a thing. It’s pretty easy once you have the coordinates from the mouse hit.

Great! Thanks for the links.

-EDIT-
After actually looking at them, I’m still completely lost. I’m not an idiot, I just don’t really understand what’s going on here. Something more step-by-step would help a lot.