Useful tips

How do I update my mesh collider?

How do I update my mesh collider?

However, you can update the collider if you are animating the mesh from a script with the Mesh API – you just need to assign the mesh to the sharedMesh property of the MeshCollider each frame.

Can you edit a mesh collider in unity?

You should not modify mesh geometry that is used for colliders because the physics engine has to rebuild an internal mesh collision acceleration structure every time you change the mesh. This causes a substantial performance overhead.

How do you update mesh in unity?

2 Answers

  1. Import the mesh into Unity.
  2. Select the prefab you want to modify in the Project Window.
  3. In the Inspector, select your new mesh from the Mesh Filter component.

How is a mesh Collider ” performance ” in Unity?

Checking two AABB’s for intersection is a very cheap operation. Only then does Unity check if the collider-geometries also collide. That means a mesh-collider only consumes CPU cycles when its bounding box intersects that of another collider.

Is it possible to update a mesh Collider?

Mesh colliders need serious pre-processing to function, and are not suitable for updating in real-time. You can’t get the updated mesh from a skinned mesh renderer for technical reasons that I forget exactly, but even if you could, it would still be very slow to compute the mesh collider.

Is it OK to change mesh geometry in Unity?

The Mesh Collider’s Cooking Options flags are set to any value other than the default. You should not modify mesh geometry that is used for colliders because the physics engine has to rebuild an internal mesh collision acceleration structure every time you change the mesh. This causes a substantial performance overhead.

Can you get updated mesh from skinned renderer?

You can’t get the updated mesh from a skinned mesh renderer for technical reasons that I forget exactly, but even if you could, it would still be very slow to compute the mesh collider. Something like a tank is trivial to do using primitive colliders, and that’s definitely the way to go.