- Home /
i need to rotate cube in z axis or x axis one direction at time
i am rotating cube on touch , if i touch and move on left side then it should rotate from left side , and if drag my touch from right side cube should move from right side , cube is placed on (0,45,0 ) rotation , i want that y axis remain same 45 every time , but other axis should be change based on touch direction here is my code
if (touchPos.x < Screen.height / 2)
{
transform.Rotate(deltaPosition.y * rotSpeed, 0, 0,Space.Self);
}
else if (touchPos.x > Screen.height / 2)
{
transform.Rotate(0, 0, -deltaPosition.y * rotSpeed,Space.Self);
}
it works on first side either on left or right , lets suppose i had rotated it from left side first then it changes on z and when z axis become 90 then next time if i will change on right side then it changes y axis and z axis too , if in first time left side will be zero then on right side if works fine , but if z goes to 90 the left side makes issue in rotation alt text
Your answer
Follow this Question
Related Questions
Smoothly rotate object based on GetAxis 1 Answer
Build rotation tool for level editor 0 Answers
Rotating Cube with oculus touch controllers 0 Answers
Rotating a bone upwards relative to camera. 2 Answers
CCTV behavior rotation issue 2 Answers