Game Engine and Assets Leaks

Tutorial: Making deformable meshes in UE4; for destructible cars & bendymetal parts

Submitted by zarrar, , Thread ID: 210787

zarrar
Junior Member
Level:
5
Reputation:
0
Posts:
53
Likes:
1
Credits:
37
29-06-2021, 11:52 AM
This post was last modified: 29-06-2021, 11:59 AM by zarrar
#1
Hello everyone!

Being a broke person, I was wondering  how I could contribute to the forum so I decided to "leak(?)" my own replication of a research paper by Dries Deryckere on making "Destructible Cars in UE4".

So far, I've had much fun ramming a standard UE4 car into the wall and watching it get squished to bits. So here's how it's done.

You will require knowledge of 3D modelling (preferably Blender as I do it in Blender) and physics assets in UE4.

Basically, we are simulating a skeletal asset with a really high physics dampening.

1. We create a skeletal mesh: You can either make your own or import a static one. Make sure that you have enough vertices on the mesh so that when we parent the bones to the mesh, each bone only gets a set amount of vertices to control (explained later).


2. We create an armature: Then we create an armature and add bones inline with the mesh at equal distance from each other. Remember the golden rule:
Higher count of bones = more realistic physics interaction
Higher count of vertices = more realistic physics interaction
but their simulation is also heavier on the system.

3. Parent armature to the mesh: Once you're satisfied with the bone positions, make sure you parent them all to one root bone, quite preferably at the center of the mesh. The go out of edit mode, select the mesh first, THEN, select the armature, hit CTRL+P AND CHOOSE "Armature Deform: With Automatic Weights". This will parent the armature to the mesh and automatically set the weights of the bones on the mesh so you don't have to manually.

4. Check bone weighting: Do a quick check to see if all bones are properly weighted. Select the armature first, THEN, select the mesh, hit CTRL+TAB and choose "Weight Paint". You'll now be in the weight paint mode. CTRL+Click a bone to see it's weighting on a mesh, to increase the weighting, simply click and hold over the area and weighting should increase (signified by the mesh color changing to red from blue). You can invert the brush weight to 0 to decrease weighting. CTRL+Click all bones to check all weightings of the bones, when satisfied, CTRL+TAB to go out of weight paint mode.

5. Export mesh and armature: Finally, if all went well, you can test the armature by going into Pose Mode and moving the bones, the specific part of the mesh that is under control of the bone should move with it. Finally we an export. Select the mesh and armature and go to File, Export, make sure you only export the current selection. Under armature settings, Uncheck Only Deform Bones and Uncheck Add Leaf Bones. Export.

6. Import to UE4 as Skeletal Mesh: Simply drag and drop the .fbx into the Content Browser and import it as a skeletal mesh. Since there are a myraid of options for importing, I'll just leave it at that, you can google how to import skeletal meshes. It's not hard.

7. Open the "Physics Asset" of your skeletal mesh: A skeletal mesh, on import, creates a skeleton and a physics asset. Open up the physics asset, you should see weird capsules inside mesh. Delete them.

8. Create new Physics Bodies: In the window that shows physics bodies, select the filter button and enable "Show all bones". Then select all bones and in the right side details panel you should see an option to create new physics bodies. Select the sphere body type and then create bodies for all bones. We won't be using these bodies but it's easier for UE4 to shift from sphere bodies to convex collision bodies. I tried making convex collision bodies directly and it kept crashing. So once sphere bodes are created, change body type to convex collision and create bodies again. This time the collision will run smoothly along the mesh instead of having spheres here and there.

9. Set dampening values of physics bodies: Now the fun part, in the Details panel of the Physics Bodies, generally located above the panel where you create physics bodies, you can find a few options. Set them as such:
  • MassInKg: CHECKED, 50.
  • Linear Dampening: 1000
  • Angular Dampening: 1000
  • Enable Gravity: UNCHECKED.
  • Physics Type: Simulated.
10. TEST MESH: That's it! Drag your mesh into the level and throw something hard at it. It should react, throw confetti or, at the very least, deform. You can check out an example on my insta page at  "https://www.instagram.com/p/CQCCPttFeb5/". Sorry it's the only place it's uploaded as of now.

Oh btw, if you want the skeletal mesh to be affected by gravity, you'll have to add it to an actor and enable gravity on the actor. It shouldn't affect the skeletal mesh then. Setting gravity enabled in the physics body will make mesh flop around like a cloth.


If you run into problems or have questions, feel free to ask.

Best Regards,
Zarrar.

Users browsing this thread: 1 Guest(s)