Slowly change an objects Z rotation to certain value

I’m trying to get an object to spin from 0 to 90 degrees on the Z axis over time, instead of instantly. I’ve tried using Vector3.Lerp, but I’m getting an error saying “The type name ‘Lerp’ does not exist in the type ‘Vector3’”.

var finalPos = new Vector3(0, 0, 90);
var desiredPos = new Vector3.Lerp(wheel.rotation, finalPos, Time.deltaTime);
wheel.rotation = Quaternion.Euler(desiredPos);

The Lerp function within the Vector3 struct is static. This means you don’t need an instance of a Vector3 to access it and so you don’t need the ‘new’ keyword as that is there for making new objects via their constructors, like you did the line before.

var desiredPos = Vector3.Lerp(wheel.rotation, finalPos, Time.deltaTime);

I’ve assumed that this is within a loop or update function, if it’s not then we might need some other changes.

Let me know if it’s not or if you need anything clarified!

@jackmw94 I put that in, but I’m getting an error saying “Argument 1: cannot convert from ‘UnityEngine.Quaternion’ to ‘UnityEngine.Vector3’”. Heres the rest of the code if that helps:

using UnityEngine;

public class Flying : MonoBehaviour
{
    public float maxHeight;
    public float rocketPower;

    public Transform[] wheels;
    public Rigidbody rb;

    void Update()
    {
        float xPos = transform.position.x;
        float yPos = transform.position.y;

        if(xPos > -16 && xPos < 30){
            foreach(Transform wheel in wheels){
                var finalPos = new Vector3(0, 0, 90);
                var desiredPos = Vector3.Lerp(wheel.rotation, finalPos, Time.deltaTime);
                wheel.rotation = Quaternion.Euler(desiredPos);
            }
            if(Input.GetKey("space") && yPos < maxHeight){
                rb.AddForce(0, rocketPower, 0, ForceMode.Impulse);
            }
        }
        else{
            foreach(Transform wheel in wheels){
                wheel.rotation = Quaternion.Euler(0, 0, 0);
            }
        }
    }
}