# LookAt

> Rotates the transform so the forward vector points at target's current position.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.0/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

## LookAt(Transform, Vector3)

Rotates the transform so the forward vector points at target's current position.

```csharp
public void LookAt(Transform target, Vector3 worldUp)
```

### Parameters

**** (\[Transform]\(/engine/6000.0/script-reference/unityengine/transform)): Object to point towards.**** (\[Vector3]\(/engine/6000.0/script-reference/unityengine/vector3)): Vector specifying the upward direction.

### Remarks

Then it rotates the transform to point its up direction vector in the direction determined by the `worldUp` parameter. 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`.

### Examples

```csharp
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);
    }
}
```

## LookAt(Transform)

Rotates the transform so the forward vector points at target's current position.

```csharp
public void LookAt(Transform target)
```

### Parameters

**** (\[Transform]\(/engine/6000.0/script-reference/unityengine/transform)): Object to point towards.

### Remarks

Then it rotates the transform to point its up direction vector in the direction determined by the `worldUp` parameter. 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`.

### Examples

```csharp
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);
    }
}
```

## LookAt(Vector3, Vector3)

Rotates the transform so the forward vector points at worldPosition.

```csharp
public void LookAt(Vector3 worldPosition, Vector3 worldUp)
```

### Parameters

**** (\[Vector3]\(/engine/6000.0/script-reference/unityengine/vector3)): Point to look at.**** (\[Vector3]\(/engine/6000.0/script-reference/unityengine/vector3)): Vector specifying the upward direction.

### Remarks

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.

### Examples

```csharp
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    void Update()
    {
        // Point the object at the world origin (0,0,0)
        transform.LookAt(Vector3.zero);
    }
}
```

## LookAt(Vector3)

Rotates the transform so the forward vector points at worldPosition.

```csharp
public void LookAt(Vector3 worldPosition)
```

### Parameters

**** (\[Vector3]\(/engine/6000.0/script-reference/unityengine/vector3)): Point to look at.

### Remarks

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.

### Examples

```csharp
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    void Update()
    {
        // Point the object at the world origin (0,0,0)
        transform.LookAt(Vector3.zero);
    }
}
```
