Rotate sprite around pivot with finger drag

[亡魂溺海] 提交于 2019-12-25 02:26:25

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!