i was wondering how i could make a car in Godot deform in a collision in real time similar to BeamNG Drive’s deforming physics, i did some tests with the Softbody node however it always sprung back to the original shape instead of being permanently deformed
You could set a function to make the softbody soft when you crash and for a short time after. After whatever time you want, you could set the linear_stiffness property of the softbody to the maximum to sort of “lock” it in place.
I would argue that you should make your own system over using Godot’s current softbody implementation. SoftBody3D does not implement the concept of plastic deformation which is the permanent deformation you’re looking for. Moreover, Godot Docs states:[1]
This doesn’t mean you need to create a complex system. Simulating the effect of plasticly deformed stiff materials, such as the metal on a car, can be done in a simple manner if you’re willing to compromise on the simulation’s degree of realism.
Proposed Method
Create a copy of the vehicle’s mesh for deformation purposes (meshDef)
When the body detects a collision, note the impact force (imp_for) and impact point (imp_pnt)
Compute the deformation for vertices within a specific radius of the imp_pnt and modulate the degree of deformation with distance and scale by imp_for.
Then apply the deformed mesh, meshDef, to the MeshInstance and accompanying collider of your vehicle.
Sidenote
The proposed method will create stretching artefacts as there is no method to preserve the surface area of the non-deformed mesh.
The proposed method is also nowhere close to BeamNG’s implementation which uses a component-based framework of springs and nodes to simulate volumetric deformation.
If you want to create a similar system, I would recommend looking at the documentation for BeamNG’s JBeam framework.