Unreal Engine can generate some simple collision for skeletal meshes, but there still may be some cases where you want to create collision volumes for your meshes in Blender. If you want volumes that fit your skeletal mesh better than the capsules and boxes generated by UE4, you can create them in Blender and import them into UE4.
In Blender, the collision geometry will be represented by a series of convex shapes (UCX meshes). For more information on collision shapes, see the Unreal Engine documentation.
Note: For static meshes, the import process is very straightforward. For skeletal meshes, this is a lot trickier. You cannot import the collision volumes with your skeletal mesh. You must import them with a static mesh and then apply them to an existing skeletal mesh. This can be a tedious process if you have volumes to import for several different bones. I would recommend only using UCX volumes where necessary and creating simple volumes in UE4 whenever possible.
Creating UCX volumes in Blender
In the blend file for your skeletal mesh, create additional mesh objects that will serve as the collision volumes. (You can always add boxes, spheres, and capsules in UE4, so you can choose to focus on just the more complex shapes here.)
Things to note:
- The names of the collision volume objects must follow this convention
UCX_[MeshName]_[##]. For example,
- The volumes must be "completely closed convex 3D shapes". (Boxes and cylinders are examples of convex shapes.)
- For best results, the documentation recommends that the volumes not overlap. Leave a small gap between each volume.
When you are ready to export:
- Select your mesh and all of the UCX objects.
- Select File → Export → FBX (.fbx)
- Choose a file name and location. Set options in the Export FBX options section. (See the settings under Exporting from Blender in this devlog post).
Importing the static mesh into UE4
This is the easiest part.
- In the Content Browser, navigate to the folder where you want the assets to be created and click on the Import button. Choose the FBX file that you exported from Blender. Click Open.
- In the FBX Import Options, you don't need to change any settings as the UCX collision volumes will be imported by default. Click Import All.
You can verify that your custom collision has been imported by opening the static mesh and ticking the Show → Simple Collision checkbox.
Adding UCX volumes to an existing skeletal mesh
- Import the static mesh (with UCX volumes) as described above.
- Open the physics asset for your skeletal mesh.
- Locate a collision volume for a physics body that you want to replace. If it doesn't exist, create a temporary one (right-click on the body, select Add Shape, and choose any shape).
- Right-click on the collision volume in the viewport. Select Copy Collision From StaticMesh and select the static mesh that you just imported. This will import all of the UCX volumes from the static mesh. (Note: They will be imported with the transform of the selected bone applied, so you may have to move them into place.)
- Delete the temporary collision volume, and delete any UCX volumes that won't belong to this bone.
- Rotate and move the UCX volumes as needed.
- Repeat steps 3 - 6 for each physics body that needs UCX volumes that you've created.