Mesh Deformation

I’m using the Unity demo, and experimenting with car physics and writing a racing game. I’m sure this has been discussed before (I tried searching, but couldn’t find anything) but is there any way to easily modify the vertexes of a mesh?

As an example of what I’m talking about, look at this…

essentially what I want is a way to dynamically wrinkle the hood of a car. It doesn’t at all need to be detailed, and certainly will not come out as well as the one pictured above.

Any and all help is appreciated!
-Max

I think scripting that is one of the most difficult ways to do that. What you really want to do is have a munch of different meshes, on for each direction of hit (front, back, side, front-left, back-right, etc). Then intantiate a bunch of rigidbodies for the little bits of the car that are flying off. In fact, have each direction in a prefab, instantiate that, and have all the rigidbodies in the prefab too. You can vary the speed of the rigidbodies (say, a hood, a side mirror, etc) dynamically, and in random directions, making the crashes each look unique. Good luck!

Look at the procedural mesh examples for examples of dynamic mesh manipulation. Pre-constructed damaged parts would mean you have the exact same damage every time…boring! :wink:

–Eric

Look also here: Unity - Scripting API: Mesh

It’s really easy to modify a mesh’s vertices.

I agree with Eric, if you want to have something that looks cool you really would have to code it. Just find some Physics books about deformation. It shouldn’t be that hard to accomplish.

Good luck.

Thank you very much!
I’ll look into that more!

EDIT:

OH, stupid me, in the procedural geometry examples there are very useful projects like… “Crumple mesh modifier”

I’ve gotten it working reasonably well, there are some glitches, but I’m happy with it overall. The size of the dents are exaggerated to make sure that it works, and will eventually be more realistic when I’m done…

web player: http://www.gotow.net/unity/DeformationTest.html

PS: It works better when it’s not in a web player… I don’t know why.