0
\$\begingroup\$

Most of the times I can use the Mesh Filter's mesh as collider in Mesh Collider

But sometimes there is just nothing. No collider. Why?

I used this free asset: https://assetstore.unity.com/packages/3d/environments/fantasy/green-forest-22762

The tree has no collider

enter image description here

\$\endgroup\$
2

2 Answers 2

1
\$\begingroup\$

The documentation says that when the object has a rigidbody, then the mesh assigned to the mesh collider must be convex. Your screenshot doesn't show whether or not there is a rigidbody on the object. But the mesh of this tree looks anything but convex and the convex checkbox on the mesh collider isn't set.

But when trees in your game don't move (as is the usual behavior of trees), you can mark your trees as "static" by marking the "Static" checkbox in the upper right corner of the inspector (unfortunately also not shown on the screenshot). They then no longer need a rigidbody themselves in order to block other rigidbodies and they can now have a non-convex mesh collider.

However, you should still consider to create simpler meshes for collision purposes. Having a large number of mesh colliders with a high number of polygons in the scene can be a real performance killer. And players rarely notice it when collision meshes are far less detailed than the meshes used for rendering. With trees it is in fact usually expected that the small branches and leaves aren't solid. Common practice for trees is to create colliders which only approximate the trunk and the largest branches.

\$\endgroup\$
0
\$\begingroup\$

Sometimes setting to convex by itself doesn't work (it didn't for me). In that case try setting to convex and then setting the cooking option "inflate convex mesh"

\$\endgroup\$
1
  • \$\begingroup\$ Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center. \$\endgroup\$
    – Community Bot
    Oct 17, 2021 at 17:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .