Unity - Scripting API: Quaternion.LookRotation
Success!
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
Submission failed
For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.
Parameters
| Parameter | Description |
|---|---|
| forward | The direction to look in, in world coordinates. |
| upwards | The vector that defines in which direction up is, in world coordinates. |
Description
Creates a rotation with the specified forward and upwards directions.
Z axis will be aligned with forward, X axis aligned with cross product between forward and upwards, and Y axis aligned with cross product between Z and X.
If the forward vector is zero, the method logs an error in the console and returns identity.
If forward and upwards are colinear, or if the magnitude of upwards is zero, the result is the same as Quaternion.FromToRotation with fromDirection set to the positive Z-axis (0, 0, 1) and toDirection set to the normalized forward direction.