How to deform a mesh (car) when it collides? (car-crash simulation)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Gamemap

How do I deform a car mesh when it is colliding? (car crash)

Is there such a thing as csg-subtraction for normal meshes?

Deforming a mesh is different than subtracting from it. Are you trying to simulate a car crash?

Bubu | 2021-04-12 11:47

Yes, I want to program a car race with accident simulation (one car crashes into a wall or several cars crash into each other)

Gamemap | 2021-04-12 14:35

You could try several methods and see which one works best. For example, you can use bones and animate them to deform the car as if it’s crashing (could be tedious, but more controllable). Or use a car that is made of different parts (maybe by slicing it randomly) and seperate the parts upon impact (Possible but I don’t know how to do it).

Bubu | 2021-04-12 20:52

Thank you for the idea with a skeleton. I think I will use it.
So there is no way to deform a mesh with only one mesh and a few lines of code?

Gamemap | 2021-04-12 22:21

It is possible to change the position of any vertex in a mesh, but the challenge is to make this modification work the way you want, You have to decide which vertices should be moved, when and what is the offset for each vertex?

Vertices are referenced by index too, so it is extremely hard to manually animate a mesh using code, using vertex shaders is easier but still not suited for animating car crashes quickly.

Skeletons are more straightforward because you can have poses that are set interactively and blend between them in a variety of ways, then finally play the deforming animations when your cars crash using code.

Bubu | 2021-04-12 23:53

I agree that moving vertices in code is difficult, but if someone wants to do this, they should take a look at the Godot MeshDataTool.

Now I have a few Ideas how I can deform my car.
Thank you very much.

Gamemap | 2021-04-13 08:21