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 |
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.