0

I am rotating a clock hand around clock center, and I am using:

Vector3 dir = mouseClickPos - transform.position;
float angle = Mathf.Atan2(dir.y,dir.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);

And it is working like a charm. But I need it not to go smooth but to skip around 15 degrees. How can I do that?

filipst
  • 1,547
  • 1
  • 30
  • 55

1 Answers1

0

Try

angle=Mathf.Round(angle/15f)*15f

(sorry for the wrong math at first, need coffee)

Krzysztof Bociurko
  • 4,575
  • 2
  • 26
  • 44