Hello, everyone.
I'm developing a pinball game, as some here already know and helped me in other situations. To finish the game, I have to fix a bug that is occurring with the marbles.
I have a ball with a sphere collider and a rigidbody on the table, which is a plan with a rigidbody and a mesh collider.
What happens is that if I keep the radius of the sphere collider exactly the radius of the ball, she gets a little inside the table, is not exactly on it. The same occurs with other objects, such as flippers, the ball gets a little inside of the flippers. Is there any way to fix this without increasing the radius of the ball?
I need to put the ball exactly over the table, not a little inside it.
Thanks!
Why not just tweak the collider radius value until you see the results you want? No one said they have to be the same.
This is because there is a penetration threshold in the physics manager, called Min Penetration For Penalty.
How deep in meters are two objects allowed to penetrate before the collision solver pushes them apart. A higher value will make objects penetrate more but reduces jitter.
Setting this to zero should in theory remove the overlap but will probably result in jittering behavior. I suggest you either expand the sphere colliders radius or contract the graphics to allow some gap between the perimeters. If you look closely in many games involving physics you'll notice that things aren't as perfect as you think. Maybe you're too picky (because most people are likely not to notice) or you should try and tweak it to more perfection. You can try adjusting the size as Derek says but you can also try adjusting the penetration threshold.