问题
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?
回答1:
Try
angle=Mathf.Round(angle/15f)*15f
(sorry for the wrong math at first, need coffee)
来源:https://stackoverflow.com/questions/24673043/rotate-sprite-around-pivot-with-finger-drag