- Home /
Ball falls through the floor... why?
I have a scene where there is a box and a ball inside it, both have rigid bodies and physic materials. The ball is launched inside the box at a random angle and speed, so the ball bounces around until it finally stops. Everything works fine... but not always. Sometimes the ball falls through the floor o passes through the walls... the problem seemed to be solved when I increased the mass of the box to 1000k but after some more testing it was clear that such change didn't solve anything...
Inside the box there is also an object with an script that modifies the speed and direction of the ball when it gets hit, but the problem doesn't seem to happen immediately after the ball hits this object... I'm not quite sure but it seems like the ball become invisible to the collision system immediately after hitting the ceiling... but again... not always.
I'm new to Unity so maybe I'm missing something... but I just can't figure out what... can anyone help?
Having object not go through colliders is a common question on UA. There is no single solution. Google searches will turn out many answers along with explanations of why the problem occurs. The single answer that seems to have the most impact is to:
Edit > Project Settings > Time
...and reduce Fixed Timestep from 0.02 to 0.01.
check for code errors as well. sometimes errors in other scripts make frame rate low, or mess with physics.
and also change collider (collision detection) settings to continuous.
It seems robertbu is right, by reducing the Fixed Timestep to 0.01 the problem seem to be solved, I still need to do more testing, but until now hasn't happened again. Thanks!!!
Answer by Bloodyem · Feb 01, 2014 at 08:38 AM
How fast is the ball moving? If it's moving too quickly, it could pass through the walls and floor without actually hitting the colliders. Check the speed it's moving when it slips through, and possibly increase the solver, sometimes that'll help.
Edit>Project Settings>Physics>Solver Iteration Count
Ok, it makes sense, the distance between the floor and the ceiling is a bit long, so when the ball hits the ceiling and falls close to a straight angle it gains a lot of speed...
Well... I increased "Solver Interaction Count" from the default (6) to 12 and nothing seems to happen, I increased it to the maximum (100) and when the ball falls straight from the ceiling it doesn't pass through the floor, however in the rebound it does... so there must be something else.
I tried the solution described by robertbu and it seems like "Fixed Timestep" has a more powerful impact in the collision detection system.
Thanks for the tip, it was useful anyway.
It does what, exactly? Its supposed to bounce, correct? Where is it going once it has bounced on the floor, or however it's rebounding?
The ball bounces correctly on the floor, but it does not collide with the floor for a second time, ins$$anonymous$$d it passes through just as if the floor wasn't there, which is curious since it looses a lot of speed after the first collision. I restored "Solver Interaction Count" to it's default (6) and reduced "Fixed Timestep" (in Edit->Project Settings->Time) to 0.01 and the problem seems to be solved... I need to do more testing but for now it seems solved.