Collision Detection for fast moving objects

Hello everyone,

I am currently working on a pinball project where I control every move of the ball itself using the transform.translate method.

We are working this way to get a full control on the ball and give it specific animation and a kind of cartoonish feature, especially when colliding with special bumpers.
Currently, the ball is “IsKinematic” and all other colliders are triggers so that I can control and calculate the collisions and rebounds by myself.

However there is a small problem : When the ball is moving fast, it passes through the triggers (the walls, the bumpers, etc.), or the OnTriggerEnter is called too late so the collision computation is incorrect.

I can somehow fix this issue by changing the FixedUpdate time step but this problem will pop up again when I increase the ball speed.
It will also be hard on the performance of the game.

Is there a simple solution other than doing all the calculations by hand ?

Thanks a lot

Don’t use transform.Translate. Doing so “teleports” the ball each time bypassing any physics considerations. Instead, use Rigidbody.MovePosition from FixedUpdate to move the ball. This also has some additional advantages:

  • You can enable continuous collision detection. Kinematic bodies support Continuous Speculative only.
  • You can enable interpolation. Ball will move smoothly regardless the fame rate or the fixed timestep.
3 Likes

Thanks !
This was exactly what I needed, there is still sometimes where the ball go through the walls, but only at extreme speeds so it’s alright !

1 Like