Smooth tire rotation

I’m trying to make a tire rotate on the Y axis for my car controller. I have a list of tire “points” that I want to smoothly rotate 45 degrees to the left and to the right based on player input.

I have been able to achieve a basic version of this using:

void Update()
        foreach (Transform tire_transform in suspension_list) {
            float rotate = Input.GetAxisRaw("Horizontal") * 45f;
            tire_transform.transform.localRotation = Quaternion.Euler(0f, rotate, 0f);

However, it has not been able to achieve a smooth transition that I want, and snaps from left to right immediately.
How do I create some sort of angle buffer / smooth the transition whilst also being able to move the local rotation depending on any Y axis value the car may be on?


You are looking about LERP variables/values. LERP is a fuction that smoothly chage some variable value.

There are several tutorials, and posts about this topic. Go learn bout it!


Thanks so much for the help!
I ended up fixing this using:

foreach (Transform tire_transform in suspension_list) {
    // returns -45 to 45
    float rotate = Input.GetAxisRaw("Horizontal") * maxTire_Angle;
    // get localRotation and desired localRotation
    Quaternion rot_initial = tire_transform.transform.localRotation;
    Vector3 rot_target_float = new Vector3(0f, tire_transform.transform.localRotation.y + rotate, 0f);
    //convert Vector3 to Quaternion
    Quaternion rot_target = Quaternion.Euler(rot_target_float.x, rot_target_float.y, rot_target_float.z);
    //lerp smoothly
    tire_transform.transform.localRotation = Quaternion.Lerp(tire_transform.transform.localRotation, rot_target, Time.deltaTime * speed);