- Home /
elastic collision simulation loses 400 kgm/s momentum in a few hours
I have made a 2D simulation of 20 balls enclosed within 4 walls, each with a velocity magnitude of 20 units/s, each with a mass of 1. all rigidbodies and colliders are elastic - 0 for friction, 1for bounce.
Initial conditions
The velocity sum along the x axis is 240.
The velocity sum along the y axis is 160.
The sum of |V|*m was 400 (20*20) at start, and I continuously printed that sum on screen, while the balls went on colliding within these 4 walls.
During runtime
after 1 second : sum = 360
after 10 minutes : sum = 250
after 4 hours : sum = 0
Motivation
Why did I do this simulation? because the ball in my arkanoid-style game loses speed over time, and I wanted to find out why. Is this due to the physics engine? shouldn't I rely on it to be accurate enough for at least a few minutes, without a need for runtime-corrections-by-code?
I know this sum does not represent how conservation of momentum works, but I start with non-zero momentum on both axis, so the simulation should not never get to 0 speed for all 20 balls.
[1]: /storage/temp/169702-untitled.jpg
Switch to calculating kinetic energy (0.5 m v^2) instead of momentum. found that the kinetic energy is not constant. After a few seconds, it is reduced from 4000 (0.5 20 400) to 3991.1, then it rises above 4000 to 4235, and simply is not constant as physics mandates. I aught to add that 1. the balls in the simulation have their Z rotation frozen 2. all objects (walls, balls) have interpolation active, and collision detection is set to "continuous".
Answer by kobyfr · Oct 23, 2020 at 12:03 PM
Is it possible to modify the parameters in "Physics 2D" to achieve a more accurate simulation?
yep, setting velocity threshold from 1 to 0.0001, get's the job done, and reduces the energy loss to a $$anonymous$$imum.
Your answer
Follow this Question
Related Questions
What is the best way to implement physic simulation prediction for AI in Unity? 1 Answer
Is there a way to create water like behavior. 0 Answers
2D physics, animation-controlled kinematic colliders not affecting momentum 1 Answer
Break 2d joint? 1 Answer
Physics2D simulation is not taking into acount the material's Friction 1 Answer