Rotate object along y axis with touch input continously
Hi!
I am trying to rotate an object according to its touch input. Everything works perfectly fine with the x-Axis. Here is the code I am using:
if(Input.touchCount == 1)
{
float rotateSpeed = 0.09f;
Touch touchZero = Input.GetTouch(0);
//Rotate the model based on offset
Vector3 localAngle = activeARfurniture.transform.localEulerAngles;
localAngle.y -= rotateSpeed * touchZero.deltaPosition.x;
activeARfurniture.transform.localEulerAngles = localAngle;
}
I if change touchZero.deltaPosition.x to touchZero.deltaPosition.y it only kinda works. There is a minor issue: When I touch and scroll horizontally the object is rotated along the x axis. If I move the finger around without lifting the finger the object follows to the left, right, left again and so on. If I enable the y axis rotation using a UI and move the finger f.e. up the object follows. But if I move the finger down without lifting it fromthe display the object stays where it is. I have to lift the finger and then move the finger down for rotating it downwards. I would like to have the same functionality that I have with the x-Axis though. Since it is the same coding I wonder why it doesnt work... Do you guys have any ideas?
Tanks in advance!
Your answer
Follow this Question
Related Questions
Android Touch - how to know on which camera i touch 0 Answers
Determine which of two rotation options is less rotation 2 Answers
Rotate an object around one of his childs in the self space (not the world space) 2 Answers
Rotate GameObject on specific axis 1 Answer
Strange rotation in my character 0 Answers