How to use the lerp function with rotation? (C#)

First of all, I’m kind of an idiot. I don’t fully grasp the concept of position changing; rotating especially. I went ahead and replaced tranform.position with .rotate in the official unity lerp tutorial.

using UnityEngine;
using System.Collections;

public class rotate : MonoBehaviour

{

public float speed;

private Vector3 newPosition;


void Awake ()
{
    newPosition = transform.rotate;
}


void Update ()
{
    PositionChanging();     
}


void PositionChanging ()
{
    Vector3 positionA = new Vector3(0, -20, 0);
    Vector3 positionB = new Vector3(0, 20, 0);
    
    if(Input.GetKeyDown(KeyCode.Q))
        newPosition = positionA;
    if(Input.GetKeyDown(KeyCode.E))
        newPosition = positionB;
    
    transform.rotation = Vector3.Lerp(transform.rotate, newPosition, speed * Time.deltaTime);
}

}

Didn’t work. Not too sure what I was expecting. If someone would be so kind as to show me the proper way to rotate and object to a degree with lerp, and better yet, explain how and why. It would be a huge step in my learning.

Thanks so much!

– Michael

transform.rotate” isn’t a thing.

transform.Rotate” is a function.

transform.rotation” is a Quaternion and should not be messed with.

transform.eulerAngles” is what you want to be modifying.

(And the manual is that way—>.)