For a project I need to do a raycast at a large nonconvex mesh collider. The models are imported from Blender and the collider is created by Unity. The raycast works great when the model is “only” 250x250 vertices, but nothing happens when the raycast hits the same model only build with 500x500 vertices. Rigidbodies collide with the object as expected.
When I make the collider convex the ray works fine again. This however is not an option since I the convex collider is not precise enough for my project. Is there a way to make the raycast hit the larger mesh collider?
What puzzles me is that the rigidbodies collide as expected. I’ve experienced some issues with large non-convex collisers such as spurious collisions, but this affects both raycasts and rb collisions. The solution was splitting the collider in smaller parts.
500 * 500 verts? This is over 64k limit (to be raised in 2017.3) and Unity will internally split it into several meshes. This is likely a bug waiting to be filed or a limitation.
I think it’s a limitation/bug because Unity’s mesh collider probably is only accessing one of those 64k chunks. It is insane to consider those poly counts to begin with.
Unity splits the model in 12 smaller meshes on import, this is fine but it doesn’t explain why the Raycast is ignored. The 250*250 model is also split in 3 smaller meshes and this is no problem for the Raycast. Maybe it’s a bug or limitation like you suggested.
Yep. I confirmed with alpha that 2017.3 will import as one chunk and no problem with mesh collider. Raycasting against meshes with these many verts is probably quite heavy performance.
Retarding the split mesh raycast issue @yant may have thoughts to share?