Colliders accuracy on moving objects

Hi there,
can somebody explain why when the collision between the 2 objects is too fast (for exemple if you control the paddle with the mouse and you want to hit the ball), then the collision is not detected and the ball is passing through the paddle?
Thx

Hi,

Welcome to our community! :slight_smile:

The physics in Unity is a simulation. For reasons of performance, everything is highly optimised. Unity does not re-calculate the entire environment a million times per second but less often.

If a game object is moving fast, it might be that the collision gets missed by the simulation due to the optimisation. You could set the collision detection mode of the Rigidbody2D component to “Continuous”. In the Physics 2D settings, you could increase a few values to achieve better results. However, this will have a negative impact on the perfomance of your game. In a little game, you probably will not notice any difference unless you increased the values too much.

In larger games with lots of objects with colliders, though, you will very likely notice a significant drop in the framerate. If you need fast moving objects, you will have to optimise the performance of everything else to compensate the negative impact of the Physics2D settings.

Increase the values slightly. Test your game. If it still runs smoothly, you may keep the values.

Did this help?


See also:

1 Like

Thank you for your reply Nina.
Unfortunately, setting the detection mode of the ball to continuous is not improving the precision of collisions. Ball is still passing through the paddle…
Which values I have to “slighly” increase ?
Thx,

Hover your mouse over the values and read the description. Maybe “Velocity Iterations” and “Position Iterations”. I usually do not change anything in the Physics2D settings, so you’ll have to test that yourself.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms