I am a noob developer, and i’m trying to rotate a cube on the y axis (only 90 degrees once then i want all rotations to stop, NOT 90 degrees every second) using lerp. When i use the code that i do, I get an error saying i cannot convert an unityengine.quaternion to a unityengine.vector3. I get this error on lines 11, 16, and 17. If anyone would be able to help me, that would be amazing, and I would be immensely appreciative. Here’s my code:
using UnityEngine;
using System.Collections;
public class rotatecube : MonoBehaviour
{
private Vector3 newPos;
Quaternion.Euler gives you a quaternion (Unity’s internal way of calculating rotations) based on the 3 Euler angle values you put into it. A Quaternion is not the same thing as a Vector 3, which is why Unity throws an error here.
But, you don’t need to use a Quaternion in your example, you can just directly create a Vector3. Like this:
Vector3 posA = new Vector3 (0, 0, 0);
Vector3 posB = new Vector3 (0, 90, 0);
after changing the quaternions to vector 3's on lines 8 and 9, i still get an error on lines 3 and 21. on line 3 the error says cannot convert quaternion into a vector 3, and then on line 21 it has the same probelm. @Hirnwirbel . pls help I would be very appreciative.
transform.rotation always returns a Quaternion.
In your Start() method, you’re trying to push a Quaternion into a Vector3 and later on the opposite. To change this simply change
If you look closely when you hover over a function like Vector3.Lerp you get to see what it returns.

In this case it says “Vector3 Vector3.Lerp” etc. Keep this in mind when assigning something to a variable that might not have the same container type. Same goes for transform.rotation.
You can see how this is a quaternion by hovering over it as well.
I hope this helped! :)
This works fixing the first problem, but for the second problem : transform.rotation.eulerangles = Vector3.Lerp (transform.rotation, newPos, Time.deltaTime); i still get an error saying cannot convert quaternion to vector3, so i decided to do this: transform.rotation.eulerangles = Vector3.Lerp (transform.rotation.eulerangles, newPos, Time.deltaTime) and i get an error that says: " cannot modify the return value of 'unityEngine.Transform.rotation' because it is not a variable" @tristantcate or anyone if you can pls help or explain this to me i'd be extremely grateful!!
after changing the quaternions to vector 3's on lines 8 and 9, i still get an error on lines 3 and 21. on line 3 the error says cannot convert quaternion into a vector 3, and then on line 21 it has the same probelm. @Hirnwirbel . pls help I would be very appreciative.
– jenniferwalsh