- Home /
HoloLens - Smooth Rotation doesn't work
Hey, i am trying to implement a smooth rotation on a game object. The following code does a 45 degrees smooth rotation around Y Axis. But when i try to rotate one more time (after inputClicked variable changed to false) it doesn't work.. Could you help me please, i am working on this since a while and still couldn't find a solution. Thanks.
public class RotateLeft : MonoBehaviour , IInputClickHandler {
public Transform objectToRotate; // The object which has to be rotated.
public float smooth = 2.5f;
public bool inputClicked;
public Vector3 rotationAngle;
public void OnInputClicked(InputClickedEventData eventData)
{
RaycastHit hit = GazeManager.Instance.HitInfo;
if (hit.transform.gameObject.tag == "Arrows")
{
inputClicked = true;
}
}
void Update()
{
if (inputClicked == true)
{
Quaternion target = Quaternion.Euler(rotationAngle);
objectToRotate.transform.rotation = Quaternion.Slerp(objectToRotate.transform.rotation, target, Time.deltaTime * smooth);
Debug.Log("ROTATE");
}
if (objectToRotate.transform.rotation.y == Quaternion.Euler(rotationAngle).y)
{
inputClicked = false;
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Quaternion Rotation Smooth 1 Answer
Smooth rotation problem 1 Answer
Flip over an object (smooth transition) 3 Answers
Choppy rotation of character around y-axis 1 Answer
Trigger diagonal rotation - Problem 2 Answers