Suggest a change
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.
Close
Sumbission failed
For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.
Close
Switch to Manual
Parameters
target |
向ける対象オブジェクト |
worldUp |
上方ベクトルを指定 |
Description
対象のTransformを設定し、その方向へと向かせます
worldUp
ベクトルが上方ベクトルの方向となり、回転を変更します。
worldUp
パラメータを省略した場合、関数はワールドのY軸を使用します。
worldUp
はベクトルのヒントのためだけに使用します。前方ベクトルが worldUp
に対して垂直である場合、 回転の上方ベクトルは worldUp
ベクトルとのみ一致します。
// This complete script can be attached to a camera to make it
// continuously point at another object.
// The target
variable shows up as a property in the inspector.
// Drag another object onto it to make the camera look at it.
var target : Transform;
// Rotate the camera every frame so it keeps looking at the target
function Update() {
transform.LookAt(target);
}
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour {
public Transform target;
void Update() {
transform.LookAt(target);
}
}
import UnityEngine
import System.Collections
public class ExampleClass(MonoBehaviour):
public target as Transform
def Update() as void:
transform.LookAt(target)
public function
LookAt(
worldPosition:
Vector3,
worldUp:
Vector3 = Vector3.up):
void;
public void
LookAt(
Vector3 worldPosition,
Vector3 worldUp = Vector3.up);
public
def
LookAt(
worldPosition as
Vector3,
worldUp as
Vector3 = Vector3.up)
as void
Parameters
worldPosition |
向かせるポイント |
worldUp |
上方ベクトルを指定 |
Description
/worldPosition/ の方向へと向かせます
worldUp
ベクトルが上方ベクトルの方向となり、回転を変更します。
worldUp
パラメータを省略した場合、関数はワールドのY軸を使用します。
worldUp
はベクトルのヒントのためだけに使用します。前方ベクトルが worldUp
に対して垂直である場合、 回転の上方ベクトルは worldUp
ベクトルとのみ一致します。
// Point the object at the world origin
transform.LookAt(Vector3.zero);
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour {
void Example() {
transform.LookAt(Vector3.zero);
}
}
import UnityEngine
import System.Collections
public class ExampleClass(MonoBehaviour):
def Example() as void:
transform.LookAt(Vector3.zero)