- Home /
Increasing unity calculation accuracy [solved]
[Edited title as it was solved]
Hi all
I'm trying to model the collisions of two blocks in unity, following this video by 3blue1brown: https://www.youtube.com/watch?v=HEfHFsfGXjs - the interesting finding (which I'm trying to model) is that the number of collisions between two objects 'traces out' the value of pi.
When I have the two cubes of mass 1 each, OnCollisionEnter correctly reports 3 collisions. When I change the mass of the cube on the right to 100 I get 31 collisions - which is again, correct. However when I change the mass of the cube on the right to 10,000 - I should get 314 collisions, but instead only 20 collisions are reported.
I've tried changing the value of the 'Default Contact Offset' in project settings / physics to a tiny value (e.g. 10^-15) and that increases the number of collisions to 167 - but further decreasing it doesn't increase the collisions beyond the 167 (curiously roughly half the correct answer, but I think that's a red herring as exactly half would be 157). I've also set collision detection on the rigibodies to be continuous, and have changed various other physics settings to no effect.
Is there another setting I should be changing to increase the accuracy or is this just a limit of Unity's modelling?
I've attached the files in case of use.
Many thanks for any help
John
Your zip link doesn't seem to work for me... however one thing I noticed that you didn't mention was messing with the fixed timestep. Have you tried setting this to a very low value?
Answer by Edy · May 05, 2021 at 09:19 AM
Love that Youtube channel!
I'd also try increasing the physics simulation frequency and the solver iterations. That should provide more accurate results. These are the options in Project Settings:
- Time > Fixed Timestep = 0.001. This is a frequency of 1000 Hz, instead of the default 50 Hz.
- Physics > Default Solver Iterations = 128. Just a large number, but you can try any other values.
- Physics > Default Solver Velocity Iterations = 128. Same, just a large number.
Your answer
![](https://koobas.hobune.stream/wayback/20220613033311im_/https://answers.unity.com/themes/thub/images/avi.jpg)