I’m doing one simple 2d game. But I do not know how to calculate the friction between the two Gameobject . As the friction between the wheels and road , I want to effect first appeared the most logical way to friction between the road and the wheel
Unity uses Box2D and you can see the source-code on GitHub. The mixing of friction/restitution can be found here.
As you can see, it takes the friction of each collider in contact and uses the square-root of the product them. For restitution (bounce) it uses the maximum of either collider.
/// Friction mixing law. The idea is to allow either fixture to drive the restitution to zero.
/// For example, anything slides on ice.
inline float32 b2MixFriction(float32 friction1, float32 friction2)
{
return b2Sqrt(friction1 * friction2);
}
/// Restitution mixing law. The idea is allow for anything to bounce off an inelastic surface.
/// For example, a superball bounces on anything.
inline float32 b2MixRestitution(float32 restitution1, float32 restitution2)
{
return restitution1 > restitution2 ? restitution1 : restitution2;
}