Search Unity

[Unity 5.6] Problem with WheelCollider

Discussion in 'Physics' started by Trese759, Apr 9, 2017.

  1. Trese759

    Trese759

    Joined:
    Nov 27, 2016
    Posts:
    36
    Hi guys, i have a problem with wheelColliders. I think is a conflict with a box collider. In the hierarchy i create an empty GameObject, my child are the body of car, the physic wheel and the wheelColliders.
    For calculate the current speed i follow a tutorial and the formula it's:

    Code (CSharp):
    1. engine.currentSpeed = 2 * (22 / 7) * wheelsCollider[2].radius * wheelsCollider[2].rpm * 60 / 1000;
    2.         engine.currentSpeed = Mathf.Abs(Mathf.Round(engine.currentSpeed));
    The wheelCollider[2] it's the BackRightWheel. When i play the current speed isn't linear but seem a random value. If I remove the Mathf.Abs the value go to negative number. How can I solve this problem.

    My car configuration:

    - MaxTorque: 50;
    - MaxSteer: 20;
    - TopSpeed: 300;
    - DecellerationSpeed: 30;

    The currentSpeed stay in a value between 0 - 100.

    Thank's in advance.