I’m developing 2D platform game. Using 2d box colliders & rigid bodies I have three kinds of objects:
- a Character
- a Crate
- a Platform
Since I don’t want Character to bounce off the Platform, but to stick to it, I set up both of their PhysicsMaterials to have Bounciness == 0. However I do want my Crate to bounce off the Platform when it falls from high enough, thus I decided to set its Bounciness to 0.2 (for now). The problem is that my Character bouncess off the Crate too now, which is undesirable.
It wouldn’t be much of an issue, because it’s hardly noticable at all… However it causes the falling animation for the Character launch several times. The trigger on the mecanim Animator that fires the animation is a bool parameter IsFalling, which I set to true, whenever Character’s rigidbody’s vertical velocity is lower than -0.001 (I had to put some threshold to avoid float precision causing my animation to fire).
It looks quite bad and I thought it’s the best to address the root cause of the problem - my Character shouldn’t bounce off the Crate at all. However from my research it seems that bounciness parameter of the Physics material always works two way and selects the net bounciness of any two objects following the maximum rule - the bigger one will be the bounciness for both of them. Unless there is a way to set this up somehow, of which I’m not aware?
The only thing I can think of now is just zeroing the vertical velocity of a Character once it lands on anything, but it looks like a bit of an workaround instead of addressing the real problem…