I need help in rotating cube by 90 degree with swipe in all axis
Hey Unity Pros,
so I want to rotate my cube in all axis back and forth with swiping. I have the part where the cube would rotate by dragging the it and rotating but I have some problems with snapping. If the distance between the start touch position is greater than 20f than snap it to the next 90 degree (eg: so if the starting rotation was 180 and the distance is greater than 20 than it would snap to 270). If the drag distance is less than 20f than it would snap back to its starting position. Now, I have the swipe distance part figured out, but whenever I try to rotate on the X axis it would go to 90 and if you would rotate once more it would go back to 0 than 270 than 0 again. I did a lot of research on this problem and if im correct its due to gimbal lock and euler angles. Now, because i havent found a solution yet this is my last option to ask the community for help.
If you guy could help me or suggest a better way of doing this I would highly appreciate it!! I dont understand how such a simple task, rotating a cube in 3axis, is so hard for me to figure out and continue the development of my game:((