I would like to have 2D bouncy balls physics.
It is with Unity Physics 2D. I set bounciness 1 and friction 0.
I tested it on flat floor and here are issues I see:
The balls keep jump higher and higher.
Balls stuck at the wall. Skip to 0:40 you’ll see there are several balls lose their X movement and stay vertically at the right wall.
Video showing the balls(starts at 0:06)
What should I do? to have
That balls don’t start to jump higher and higher. I tried to set less bouncy like 0.99 but it works different with lags on lower fps. So it seems not a solution.
That balls don’t lose their X movement of the walls.
Physics runs during the fixed-update and is frame-rate independent so it won’t have any effect on it at all. What will have an effect is if you’re performing work per-frame or in a way that isn’t frame-rate independent.
The lack of bounce is probably the Velocity Threshold which, as the docs state, any collisions with a relative linear velocity below this threshold will be treated as inelastic (no bounce). Set this to zero should solve that assuming this is your issue.
The 2D physics system (Box2D) doesn’t conserve energy perfectly with a bounce of 1 and it can vary depending on various factors. It’s approximate only.
However. Is there a way to make a ball to want to jump? Not sure how to explain.
Like the ball want to jump at some minimum force. So for example the bounciness set to 90% and a ball jumps less and less speed. But when the speed is lower than a certain threshold then the ball thinks “That is lower than the minimum so I want to jump higher”.
This way when the jump force will become less then a ball will increase it, so this way will generate something like balance situation where the ball jumps around the same force.
You can do this but it’s obviously custom behaviour. Either modify the velocity yourself upon contact using a Dynamic body and callback or use a Kinematic body and detect collisions yourself using queries (CircleCast maybe) then you can perform your own response as you like.