Search Unity

Smooth direction of car

Discussion in 'Scripting' started by Zavalichi, May 18, 2019.

  1. Zavalichi

    Zavalichi

    Joined:
    Oct 13, 2018
    Posts:
    162
    Hi guys,
    I have a problem with my car, if I press left arrow the car turn left instant, can you help me?
    Code (CSharp):
    1.  wheels.wheelFL.steerAngle = Mathf.Lerp(wheels.wheelFL.steerAngle, maxSteer * Input.GetAxis("Horizontal"), Time.deltaTime + 5);
    2.             wheels.wheelFR.steerAngle = Mathf.Lerp(wheels.wheelFL.steerAngle, maxSteer * Input.GetAxis("Horizontal"), Time.deltaTime + 5);
    upload_2019-5-18_17-45-26.png
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,742
    Remove the +5 after Time.deltaTime on both lines.

    If you need the slewing to be faster or slower, you can MULTIPLY the Time.deltaTime by a value, but for now leaving it alone should give you a baseline.