Creating Collision Volumes for UE4

March 04, 2020


Contents


Introduction

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, UCX_MyRobot_00, UCX_MyRobot_01, UCX_MyRobot_02, etc.
  • 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:

  1. Select your mesh and all of the UCX objects.
  2. Select FileExportFBX (.fbx)
  3. 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 UE4:

  1. 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.
  2. 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 ShowSimple Collision checkbox.

Adding UCX volumes to an existing skeletal mesh

In UE4:

  1. Import the static mesh (with UCX volumes) as described above.
  2. Open the physics asset for your skeletal mesh.
  3. 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).
  4. 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.)
  5. Delete the temporary collision volume, and delete any UCX volumes that won't belong to this bone.
  6. Rotate and move the UCX volumes as needed.
  7. Repeat steps 3 - 6 for each physics body that needs UCX volumes that you've created.