I have a complicated mesh that doesn't need to have anything to do with physics. However, I need to be able to detect said mesh with a raycast from a point. I have several hundred of these objects that regularly get moved around and rescaled, so a mesh collider is way too computationally expensive - especially since I don't need any form of collision detection other than this raycast. However, the mesh is human-shaped, and is thus irregular enough that I can't just use lots of primitives, nor can I just check if the mouse point is within a specified area (since the area is far too complex to manually specify). Turning the mesh collider off when it's not relevant works a little, but the act of turning the collider on and off is ALSO computationally expensive enough to cause noticeable frame drops. What component or settings can I use in order to raycast a mesh without all the slowdown of a mesh collider?

  • \$\begingroup\$ Regarding making your current collider solution more efficient: you may want to try adding a kinematic Rigidbody, and setting the mesh collider to be a trigger, on its own layer that collides with nothing. The kinematic body ensures Unity knows it will move, so it doesn't ask the physics engine to rebuild the static collision acceleration structures every time you turn it on/off. And by being on its own non-interacting layer, it should incur zero collision checks apart from the rays you fire. Making it a trigger should skip any inertia tensor recalculation too. \$\endgroup\$
    – DMGregory
    Commented Feb 19, 2020 at 2:01

1 Answer 1


A similar question was asked before so I'll just re-post the answer 'Kay' provided.

  • Use compound colliders especially box and sphere s Rigidbody manual
  • Always attach rigidbodies to moving items
  • If you need more than one raycast consider using Physics.RaycastAll
  • If the physics engine is to blame for significant frame rate Drops, check whether you can use layers to optimise calculations
  • Use the profiler

You must log in to answer this question.

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