- Home /
Remove Y-axis clamp from Tap to Move, Drag to Look Script
Hello,
I got a Tap to Move, Drag to Look script from the unify wiki:
And it works a treat, except the y axis is restricted and i can't see why. I've had a good look at the code, and considering it's C# and i'm used to Java, i'm pretty sure i'm misunderstanding something in the rotate function.
void Rotate()
{
Vector3 lastDirectionInGlobal = _camera.ScreenPointToRay(rightFingerLastPoint).direction;
Vector3 currentDirectionInGlobal = _camera.ScreenPointToRay(rightFingerCurrentPoint).direction;
Quaternion rotation = new Quaternion();
rotation.SetFromToRotation(lastDirectionInGlobal, currentDirectionInGlobal);
ownTransform.rotation = ownTransform.rotation * Quaternion.Euler(0, kInverse ? rotation.eulerAngles.y : -rotation.eulerAngles.y, 0);
// and now the rotation in the camera's local space
rotation.SetFromToRotation( cameraTransform.InverseTransformDirection(lastDirectionInGlobal),
cameraTransform.InverseTransformDirection(currentDirectionInGlobal));
cameraTransform.localRotation = Quaternion.Euler(kInverse ? rotation.eulerAngles.x : -rotation.eulerAngles.x, 0, 0) * cameraTransform.localRotation;
rightFingerLastPoint = rightFingerCurrentPoint;
}
Any tips would be greatly appreciated.
Thanks.
Simon.
Comment
Your answer
Follow this Question
Related Questions
How to make camera position relative to a specific target. 1 Answer
Finding the centre of two touches 2 Answers
touch game objects on ios 1 Answer
Detect a tap versus standing touch on iPhone? 3 Answers
Tap Control on Android 1 Answer