Version: 2021.1
言語: 日本語
public void LookAt (Transform target);
public void LookAt (Transform target, Vector3 worldUp= Vector3.up);

パラメーター

target 向ける対象オブジェクト
worldUp 上方ベクトルを指定

説明

対象の Transform を設定し、その方向へと向かせます

Then it rotates the transform to point its up direction vector in the direction hinted at by the worldUp vector. If you leave out the worldUp parameter, the function will use the world y axis. The up vector of the rotation will only match the worldUp vector if the forward direction is perpendicular to 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); } }

public void LookAt (Vector3 worldPosition);
public void LookAt (Vector3 worldPosition, Vector3 worldUp= Vector3.up);

パラメーター

worldPosition 向かせるポイント
worldUp 上方ベクトルを指定

説明

worldPosition の方向へと向かせます

Then it rotates the transform to point its up direction vector in the direction hinted at by the worldUp vector. If you leave out the worldUp parameter, the function will use the world y axis. The up vector of the rotation will only match the worldUp vector if the forward direction is perpendicular to worldUp.

using UnityEngine;

public class ExampleClass : MonoBehaviour { public Transform target;

void Update() { // Point the object at the world origin (0,0,0) transform.LookAt(Vector3.zero); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961