Optimize physics calculations by configuring the cooking options for MeshThe main graphics primitive of Unity. Meshes make up a large part of your 3D worlds. Unity supports triangulated or Quadrangulated polygon meshes. Nurbs, Nurms, Subdiv surfaces must be converted to polygons. More info
See in Glossary ColliderAn invisible shape that is used to handle physical collisions for an object. A collider doesn’t need to be exactly the same shape as the object’s mesh - a rough approximation is often more efficient and indistinguishable in gameplay. More info
See in Glossary components.
When you select a GameObjectThe fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is defined by the Components attached to it. More info
See in Glossary with a Mesh ColliderA free-form collider component which accepts a mesh reference to define its collision surface shape. More info
See in Glossary component in the Editor, you can modify the Cooking Options property in the InspectorA Unity window that displays information about the currently selected GameObject, asset or project settings, allowing you to inspect and edit the values. More info
See in Glossary window. Set this property to define how to process this mesh for physics calculations. Cooking options affect both cooking time and runtime performance. You can select more than one of the available options to combine them.
When you set the Cooking Options property for a component, you define how to cook that particular mesh. To learn more about how to set options for cooking meshes for the whole simulation, refer to Prepare meshes for mesh colliders.
To learn about what properties are available for the Mesh Collider component, refer to Mesh collider component reference.
The cooking options are:
The recommended best practices to configure Mesh Collider cooking options are:
The recommended performance tips for using Mesh Collider components in general are:
To evaluate Mesh Collider performance:
Profile: Use the Unity Profiler. Focus on narrow phase processing and Physics solve times when the object with the Mesh Collider is actively colliding. High values can indicate a Mesh Collider that is resource-intensive. Also, watch for runtime mesh cooking spikes if meshes aren’t pre-cooked.
A/B test: Compare performance. Create a test scenario with your GameObject that has the Mesh Collider attached. Then, create a version of the same GameObject that has a compound collider approximation attached. Test both under identical collision conditions, and compare ProfilerA window that helps you to optimize your game. It shows how much time is spent in the various areas of your game. For example, it can report the percentage of time spent rendering, animating, or in your game logic. More info
See in Glossary data.
Consider alternatives: If a Mesh Collider is affecting performance, consider alternatives:
Separate the graphic representation of the mesh from its physics representation to simplify its mesh. You might want to use different GameObjects so the physics system can use a separate, simplified mesh. For more information, refer to Prepare meshes for mesh colliders.
If you have dynamic objects, consider using a compound collider to achieve collision fidelity.
Remember that for dynamic RigidbodyA component that allows a GameObject to be affected by simulated gravity and other forces. More info
See in Glossary and Mesh Collider components, they must be convex. If concave dynamic collision is needed, compound colliders are the standard approach.