docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method LookAtRotation

    LookAtRotation(in float3, float3, float3)

    Computes a rotation so that "forward" points to the target.

    Declaration
    public static quaternion LookAtRotation(in float3 eyeWorldPosition, float3 targetWorldPosition, float3 worldUp)
    Parameters
    Type Name Description
    float3 eyeWorldPosition

    The 3D position of the viewer (the "eye"), in world-space.

    float3 targetWorldPosition

    The 3D position the viewer wants to rotate to face, in world-space

    float3 worldUp

    The direction in world-space that represents "up". When in doubt, Unity.Mathematics.math.up() is often a safe bet.

    Returns
    Type Description
    quaternion

    A quaternion containing the rotation which would cause a viewer at eyeWorldPosition to face targetWorldPosition, with the "up" direction in the resulting reference frame corresponding as closely as possible to .

    Remarks

    Note that the viewer's existing orientation is ignored; the quaternion returned by this function should replace the viewer's rotation, not be added to it.

    In This Article
    Back to top
    Copyright © 2024 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)