x


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:

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.

more ▼

asked May 06 '12 at 07:07 AM

siberman gravatar image

siberman
31 11 13 15

(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1968
x727
x583
x224
x39

asked: May 06 '12 at 07:07 AM

Seen: 521 times

Last Updated: May 06 '12 at 07:07 AM