Reputation: 6193
I am trying to rotate a game object using the lerp command, however I am getting the following error:
error CS0029: Cannot implicitly convert type
float' to
UnityEngine.Quaternion'
This is the code I am using
box.rotation = Quaternion.AngleAxis(NewAngle, Vector3.right);
boxAngle = box.rotation.x;
targetAngle = 90.0f;
NewAngle = Mathf.Lerp(boxAngle, targetAngle, smooth * Time.deltaTime);
Could anyone point me in the right direction? What am I doing wrong?
Upvotes: 0
Views: 1347
Reputation: 4662
Assuming box
is an Transform
, this should work, but if you're rotating only on one axis it will be much easier to use
box.eulerAngles=new Vector3(NewAngle, 0f, 0f);
Also, there other two potential issues:
How about:
Quaternion targetAngle=Quaternion.Euler(90f, 0f, 0f);
box.rotation=Quaternion.Lerp(box.rotation, targetAngle, Time.deltaTime*smooth);
Upvotes: 4