Terraindeformation under a trenchobject

Hello,

In my project the player should be able to create trenches. These consists of gameobjects which are “digged” in the terrain. The placing of the trenches wors alright so far but I want your advice on the terraindeformation. I have several ideas but I cant decide which way to go so I hope you can tell me your thoughts on this.

Right now it looks like this:

The terrain is lowered where the trenchsegment ist instantiated.Well after all…
How would you proceed? I think about using cosinus and so on and solve this purely mathematically. But then there is stuff like renderer.bounds or the contact points of the colliders…Ideally the terrain will adjust to the trench because later on there will be other trenchshapes.

Here is a video of a nice example

Sincerely,
Hardliner

Here is one thing, mostly intended for authoring time:

https://www.youtube.com/watch?v=FykNmJ3NIpI

In my makegeo project there is a TerrainDamager.unity that can give you ideas about runtime terrain deformation.

MakeGeo is presently hosted at these locations:

https://bitbucket.org/kurtdekker/makegeo

Hey I’m sorry for the late reply. I wasn’t able to find some time to look in the forum. Thank you for your answer. I will take a look into your project.

Sincerely
Hardliner

Hello,

I looked into terrain.damager which is indeed revealing.
But what did you do for the terrain to collider script in your video? Did you used any attributes of the mesh in the script?
Something like contact.points or whatever?

Sincerely
Hardliner

The source code for both the video and also the grenade lobber one are both linked. You can study and see all the steps for yourself. There’s even comments!

Oh damn! I’m sorry! I just watched the video here in the thread without clicking on it so I missed the link. I searched for the script in your project.
I looked at your script and I think it answered all my questions. I should be able to do something similiar on my project.
Thanks a lot!

1 Like