docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method GetCameraRotationToTarget

    GetCameraRotationToTarget(Quaternion, Vector3, Vector3)

    Get the rotations, first about world up, then about (travelling) local right, necessary to align the quaternion's forward with the target direction. This represents the tripod head movement needed to look at the target. This formulation makes it easy to interpolate without introducing spurious roll.

    Declaration
    public static Vector2 GetCameraRotationToTarget(this Quaternion orient, Vector3 lookAtDir, Vector3 worldUp)
    Parameters
    Type Name Description
    Quaternion orient
    Vector3 lookAtDir

    The world-space target direction in which we want to look

    Vector3 worldUp

    Which way is up. Must have a length of 1.

    Returns
    Type Description
    Vector2

    Vector2.y is rotation about worldUp, and Vector2.x is second rotation, about local right.

    In This Article
    Back to top
    Copyright © 2023 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)