hi, im new to unity and have a problem with making a cube rotate,
this is the code im using and its attached to a cube:
Vector3 myRotation = new Vector3(0,0,0);
bool rotate = false;
void Update ()
{
if (rotate)
{
transform.Rotate(myRotation);
}
switch(Input.inputString)
{
case "d":
rotate = true;
myRotation.y = 2;
break;
case "a":
rotate = true;
myRotation.y = -2;
break;
case "":
rotate = false;
myRotation.y = 0;
break;
case default (string):
rotate = false;
myRotation.y = 0;
break;
}
if (rotate)
{
transform.Rotate(myRotation);
}
}
the problem is that the cube doesnt instantly, or smoothly, rotate but instead waits for about a second and then sdtarts rotating.
can anyone help me with getting this to rotate smoothly?