| target | 要指向的对象。 | 
| worldUp | 指定向上方向的向量。 | 
旋转变换,使向前向量指向 /target/ 的当前位置。
然后它旋转变换,使其向上方向向量指向由 worldUp 向量暗示的方向。如果您省略了 worldUp 参数,则该函数将使用世界 y 轴。旋转的向上向量将仅在向前方向垂直于 worldUp 向量时才与 worldUp 向量匹配。
using UnityEngine; // This complete script can be attached to a camera to make it // continuously point at another object.
public class ExampleClass : MonoBehaviour { public Transform target;
void Update() { // Rotate the camera every frame so it keeps looking at the target transform.LookAt(target);
// Same as above, but setting the worldUp parameter to Vector3.left in this example turns the camera on its side transform.LookAt(target, Vector3.left); } }
| worldPosition | 要查看的点。 | 
| worldUp | 指定向上方向的向量。 | 
旋转变换,使向前向量指向 worldPosition。
然后它旋转变换,使其向上方向向量指向由 worldUp 向量暗示的方向。如果您省略了 worldUp 参数,则该函数将使用世界 y 轴。旋转的向上向量将仅在向前方向垂直于 worldUp 向量时才与 worldUp 向量匹配。
using UnityEngine;
public class ExampleClass : MonoBehaviour { void Update() { // Point the object at the world origin (0,0,0) transform.LookAt(Vector3.zero); } }