How can I cause a sphere to bounce infinitely without gaining or losing any energy?
I'm trying to create a sphere that bounces forever, and after each bounce, it always reaches a fixed height.
I added a physic material to a sphere. I set Dynamic and Static Friction to 0, Friction Combine to "Minimum", Bounciness to 1, and Bounce Combine to "Maximum". But unfortunately, the sphere gains energy after each bounce. This results in the sphere gaining height during each bounce.
I've searched for solution online which do not require any code. But none of them are useful. My only option is to use code. Is there a way I can cause the sphere to bounce forever, without gaining or losing energy, so that it always reaches the same height after every bounce?
A terrible, terrible way is setting drag to a small number to compensate. 0.016 gave pretty good results (with a 10 meter drop - lower hts seem to need more drag.)
For fun, continuous dynamic doesn't help.
Answer by lukemorel · Dec 28, 2016 at 05:20 PM
Be careful to the physic material applied on the platform you bounce on, try to add a material with zero friction. The standard assets contain some physic materials, one of them is called ZeroFriction which should be what you need for your platform : (note the 'Multiply' friction combine option which will keep friction to 0 :P)
If you are on a terrain, just click on it, then you can change the physic material under the Terrain Collider option,
If you are on a plane, or any other 3D object, you know how to change it ;)
If you read the second paragraph from the OP, they already have friction set to 0. As they note, this doesn't work. The object will almost always fall a little bit into the floor during a time step. The system corrects that, but it gives some inexactness in the return bounce.
There's also nothing special about the premade physics $$anonymous$$aterials. It's easy and, I think, better, to just make and set your own (as the OP did.)
The second paragraph talks about the sphere friction, I talk about the surface the sphere bounce on. You have 2 surfaces and 2 physic materials to play with.
The premade ZeroFriction physic material is just, in my opinion, a good point to start with :)
For fun I rechecked this (using version 5.2x). Friction and ground materials don't matter. Bounce 1/maximum on a ball is the same no matter what else you do:
o Friction has no effect on bouncing. 0 or 1 gives the same amount of bounce. I think the actual rule is that friction is applied if you were in contact last frame, and are in contact this frame (which doesn't happen when you bounce.)
o If you override the ground settings (ex: bounciness 1/maximum) then having or not having a physics material on the ground has no effect. I believe this is on purpose - I think the old manual suggested, at first, using max/$$anonymous$$ settings to avoid needing a physics material on every surface.
Answer by mbmt · Mar 13, 2020 at 07:48 AM
The ancients say that the ideal value of bounciness for infinity bounce is something around 0.9803922