Collider does not fully adhere to ground, missing friction

I have a bike sprite with wheels having a Circle Collider 2D, a Rigidbody 2D and a Wheel Joint 2D.
The Rigidbody has a Physics material with Friction set to 1.

The track is a simple polygon collider.
Unfortunately, when I am activating the motor of the Wheel Joint, the wheel is turning and not really adhering well to the track, preventing it to climb as you can see on the video. Any idea on how to have 100% friction ?



Actually, configuring physics can be quite complex, requiring experimentation with masses, friction, and other properties.

The thing is, friction for a physical material can be set higher than one. For example, I tried setting it to 2000 and applied this material only to the driving wheel. All other parameters on physical objects are set to default. The only thing I changed was swapping the WheelJoint for a HingeJoint. I remember trying something similar to your motorcycle with a WheelJoint, but struggled all day with constant jerking while riding, and so on. In the end, I switched to a HingeJoint (which also has a motor) and everything worked fine.

In the example below, there’s a very simple scene. Here’s one driving wheel (the one with spokes). Its speed depends on the mouse position; the further the mouse is from the center of the screen, the greater the speed in that direction.

Speed script

using UnityEngine;

public class MainWheelController : MonoBehaviour
{
    public float SpeedForce = 10;
    public bool EnableColliderVisible = true;

    private HingeJoint2D _hingeJoint2D;
    private JointMotor2D _motor;

    void Start()
    {
        _hingeJoint2D = GetComponent<HingeJoint2D>();
        _motor = _hingeJoint2D.motor;
    }

    void Update()
    {
        _motor.motorSpeed = (Input.mousePosition.x - (Screen.width / 2)) * SpeedForce;
        _hingeJoint2D.motor = _motor;
    }

    private void OnGUI()
    {
        GUILayout.Label("  SPEED:" + _motor.motorSpeed);
    }

    private void OnValidate()
    {
        Physics2D.alwaysShowColliders = EnableColliderVisible;
    }
}

As you can see, you can even ride on the ceiling. But of course, it’s not guaranteed that you won’t have to adjust something else additionally, such as the mass and friction of the ground, etc.

Just in case, here’s the package.

9782745–1403028–BikeFrictionExample.unitypackage (9.61 KB)

1 Like

Thank you, I really appreciate ! Also the Hinge Joint made it much better.