- Home /
Rigidbody skipping over colliders
Hi all,
I have seen this question asked before but so far have not found a working solution.
I have a 3d scene made up of tiles of various shapes. Most of these tiles are 1x1x0.2 in scale (but I am planning on having different scales and shapes) and have a mesh collider and a physical material attached. I have a ball with a rigidbody and a sphere collider. When I apply a reasonably fast force (think putting in golf) to the ball is skips/hits/bounces at the joins of the tiles.
I have read that it is an issue with mesh colliders and I should use box or primative colliders instead, but this will limit the shape of tiles I can have. I am using 2017.3 so have no setting for 'Min penetration for penalty' that some answers have suggested. I have changed the rigidbody collision detection to 'Discrete' and that seems to eliminate the issue but I am worried as it can cause odd collision detection.
There have been some suggestions to change the 'Fixed timestep' but that would require a reqork of my force calculations and animations etc... I also want to avoid adding extra box colliders between the seams as again this would limit level design and add quite a lot of work to the building of each level.
Any help would be greatly appreciated as this seems to be a common issue for people working with tiles and so far I haven't found a true solution.
Thanks in advance.
Answer by RobAnthem · Mar 13, 2018 at 04:11 PM
Usually what people do is create a single collider for all flat surfaces. If it is not flat, you should be using something like a Terrain or modeled plane. Otherwise you may need to look into advanced procedural meshes to combine your meshes into a single mesh. The reason it is happening, is because every time the ball hits another collider, it calculates the physics again, and it counts it as a new collision, so when it hits the corner edge of the collider, it will arc over, or skip as you see it.
@RobAnthem is right. For Unity, collisions with "regular shapes" is pretty good, but if you commence to create collisions with curved edges, there will be multiple-simultaneously collisions that need to be calculated. This create errors and problems.... Thats why people try to avoid this kind of collisions.
$$anonymous$$aybe you need to rethink the shapes of your tiles and use non curve edges.
Bye :D
Answer by AndrewIanBurrow · Mar 15, 2018 at 04:23 PM
Thanks guys for the advice and replies.
I have decided to go a different route and to build all levels in Blender then import them in and either use one main mesh collider or build up the colliders using either boxes or other primative types depening on the situation.
It has also made me re-evaluate my graphics and lighting and I am now using a mixture of baked and dynamic which is giving much better results...so win-win.
Thanks again.