Fast moving objects and mesh colliders (physics)

Hi,

Just posting a solution to a problem I had the other day when working on my game. It’s related to fast moving physics objects that collide with mesh colliders which sometimes makes them go through the geometry. If this happens - try increasing simulation step of the physics engine. This is not documented in PlayCanvas but if you look through “Bullet” physics engine documentation you can find it. To increase time step of rigidbody simulations do:

app.systems.rigidbody.fixedTimeStep = 1/60; //update physics simulation every 0.0166s
app.systems.rigidbody.fixedTimeStep = 1/120 // update physics simulation every 0.0083s (twice the speed of the above)

Of course be mindful of performance and always test your changes.

Hope this helps someone.

2 Likes

Thank you for posting the finding!
There is another one: maxSubSteps which limits number of maximum steps. By default it is 10. Means, if your application FPS is more than 10 times lower than expected frequency of fixedTimeStep (by default 1/60), then it will lead to problems.
Basically, if you increase fixedTimeStep to 1/120, and your fps goes below 12, then you will get physics quality degradation and slow downs.
And do remember, doing 1/120 pretty much doubles the computation required by physics, as it will do at least 2 steps now, as your browser usually renders maximum of 60 frames a second, unless you are on high Hz monitors, like 144Hz ones (love them! :slight_smile: ).