In order to make a Static Mesh part of the physics simulation in a Level, you have to set it up with a Collision Mesh. This represents the bounds of the Static Mesh object within the physics simulation. The physics system uses this Collision Mesh whenever it needs to check whether other physical objects collide with your mesh, and whenever you conduct a high-performance raycast to test for collisions against your mesh. You could use the visible geometry of the Static Mesh as its Collision Mesh, but the visible geometry is typically far too detailed. Physical interactions do not usually need this high level of accuracy in order to provide realistic results. Therefore, you can improve the performance of the physics system by making your Collision Meshes as simple as possible.
You can create simplified collision representations for your Static Meshes automatically in the Static Mesh Editor:
Click for full image.
For details, see Setting Up Collisions With Static Meshes.
In some cases, you may need to create these Collision Mesh representations programmatically, instead of doing it by hand in the Static Mesh Editor. For example, if you need to set up a large number of Static Mesh objects in the same Project, it may not be feasible to open each one in turn. Or, you may want to carry out the collision setup as one step in a larger automated pipeline for importing and managing content.
The following sections illustrate how you can use Blueprints and Python to apply the different types of simple and convex Collision Meshes shown above to your Static Mesh Assets automatically in the Unreal Editor.
You can't yet use Blueprint or Python to import another Static Mesh and use it as a custom Collision Mesh. To do this, you have to either:
- Use the Static Mesh Editor user interface to import the Collision Mesh from a supported file format.
- Import the Collision Mesh at the same time as the visible Static Mesh, using a special naming convention to indicate that it represents the geometry you want to use for collision testing. For details, see FBX Static Mesh Pipeline, or Datasmith Overview.