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

Parámetros

targetObjeto para apuntar hacia.
worldUpVector especificando la dirección hacia arriba.

Descripción

Gira el transform para que el vector hacia adelante apunte en la posición actual del target.

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. worldUp is only a hint vector. The up vector of the rotation will only match the worldUp vector if the forward direction is perpendicular to 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. using UnityEngine; using System.Collections;

public class ExampleClass : MonoBehaviour { public Transform target;

void Update() { // Rotate the camera every frame so it keeps looking at the target transform.LookAt(target); } }

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

Parámetros

worldPositionPunto a mirar.
worldUpVector especificando la dirección hacia arriba.

Descripción

Gira el transform para que el vector hacia adelante apunte a 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. worldUp is only a hint vector. 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 transform.LookAt(Vector3.zero); } }