I want to rotate around an object with the camera and the gesture code works on doing that to a certain extend. This is the code:
if (gesture.deltaPosition.x>0)
{
rotationX -= gesture.deltaPosition.x*Time.deltaTime;
transform.RotateAround( referenceCamera.up, Mathf.Deg2Rad * rotationX);
Debug.Log ("To left x="+gesture.deltaPosition.x);
}
else if (gesture.deltaPosition.x<0)
{
rotationX -= gesture.deltaPosition.x*Time.deltaTime;
transform.RotateAround( referenceCamera.up, Mathf.Deg2Rad * rotationX);
Debug.Log ("To right x="+gesture.deltaPosition.x);
}
else
{
}
if (gesture.deltaPosition.y>0)
{
rotationY += gesture.deltaPosition.y*Time.deltaTime;
transform.RotateAround( referenceCamera.right, Mathf.Deg2Rad * rotationY);
Debug.Log ("Positive y="+gesture.deltaPosition.y);
}
else if (gesture.deltaPosition.y<0)
{
rotationY += gesture.deltaPosition.y*Time.deltaTime;
transform.RotateAround( referenceCamera.right, Mathf.Deg2Rad * rotationY);
Debug.Log ("Negative y="+gesture.deltaPosition.y);
}
else
{
}
The problem is that if you are moving to one direction, and you reverse the gesture, the movement is still towards the first direction for a while, even with the Debug telling me that deltaPosition has inverted. I am confused here. Any help?
Regards
Carlos