Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to get steer angle of wheel collider

Discussion in 'Physics' started by essex, Feb 18, 2015.

  1. essex

    essex

    Joined:
    May 4, 2013
    Posts:
    1
    Hello,

    I am a beginner of unity.
    I am learning the unity by leading sample projects -Car tutorial-.
    Now I want to know how to get current steer angle.

    Reference of unity said that -Wheel collider always keep the steer angle-.
    Therefor I added the code into the update function of Car.js such as follow.

    function Update()
    .....
    for(var w : Wheel in wheels)
    {
    var wheel : WheelCollider = w.collider;
    if (w.steerWheel == true){
    Debug.Log(wheel.steerAngle);
    }
    }

    But I could not get it.
    And I tried to add following code into the UpdateWheelGraphic function.

    function UpdateWheelGraphics
    .....
    if(w.steerWheel){
    w.wheelVelo *= 0.9;
    //And I tried to add following code here.
    steerAngle = wheel.steerAngle;
    Debug.Log(steerAngle);
    }
    else
    w.wheelVelo *= 0.9 * (1 - throttle);


    But I could not get it at hear also .
    So, What wrong my additional code?

    thank you,