Hello,
I got a Tap to Move, Drag to Look script from the unify wiki:
link text
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.
asked
May 06 '12 at 07:07 AM
siberman
31
●
11
●
13
●
15