# Project

> Projects a vector onto another vector.

## Definition

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

## Project(Vector3, Vector3)

Projects a vector onto another vector.

```csharp
public static Vector3 Project(Vector3 vector, Vector3 onNormal)
```

### Parameters

**** (\[Vector3]\(/engine/6000.5/script-reference/unityengine/vector3)): The vector to project.**** (\[Vector3]\(/engine/6000.5/script-reference/unityengine/vector3)): The vector to project onto. This vector doesn't need to be normalized.

### Returns

| Type                                                              | Description                                                                                                      |
| ----------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| [Vector3](/engine/6000.5/script-reference/unityengine/vector3.md) | The vector that results from the projection of `vector`. This vector points in the same direction as `onNormal`. |

### Remarks

The resulting projection is the amount of `vector` that points in the same direction as `onNormal`.

![Vec3ProjectDiagram (Project)](/api/media?file=/engine/6000.5/media/images/Vec3ProjectDiagram.png)

Diagram showing a vector projected onto the vector `onNormal`. The projected vector extends past `onNormal` in the same direction because the magnitude of `vector` in the direction of `onNormal` is greater than the magnitude of `onNormal`. The result points to the point along the infinite line in the direction of `onNormal` that's closest to the point specified by `vector`.

The function returns a zero vector if `onNormal` is almost zero. `onNormal` doesn't need to be a normalized vector.

You can use projection to work out the closest point along a line to a target vector. This information can be useful for moving or orienting items in the direction of a moving target.

### Examples

```csharp
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour
{
    void Slide(Transform target, Vector3 railDirection)
    {
        Vector3 heading = target.position - transform.position;
        Vector3 force = Vector3.Project(heading, railDirection);

        GetComponent<Rigidbody>().AddForce(force);
    }
}
```

## Project(Vector3, Vector3)

Projects a vector onto another vector.

```csharp
public static Vector3 Project(in Vector3 vector, in Vector3 onNormal)
```

### Parameters

**** (\[Vector3]\(/engine/6000.5/script-reference/unityengine/vector3)): The vector to project.**** (\[Vector3]\(/engine/6000.5/script-reference/unityengine/vector3)): The vector to project onto. This vector doesn't need to be normalized.

### Returns

| Type                                                              | Description                                                                                                      |
| ----------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| [Vector3](/engine/6000.5/script-reference/unityengine/vector3.md) | The vector that results from the projection of `vector`. This vector points in the same direction as `onNormal`. |

### Remarks

The resulting projection is the amount of `vector` that points in the same direction as `onNormal`.

![Vec3ProjectDiagram (Project)](/api/media?file=/engine/6000.5/media/images/Vec3ProjectDiagram.png)

Diagram showing a vector projected onto the vector `onNormal`. The projected vector extends past `onNormal` in the same direction because the magnitude of `vector` in the direction of `onNormal` is greater than the magnitude of `onNormal`. The result points to the point along the infinite line in the direction of `onNormal` that's closest to the point specified by `vector`.

The function returns a zero vector if `onNormal` is almost zero. `onNormal` doesn't need to be a normalized vector.

You can use projection to work out the closest point along a line to a target vector. This information can be useful for moving or orienting items in the direction of a moving target.

### Examples

```csharp
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour
{
    void Slide(Transform target, Vector3 railDirection)
    {
        Vector3 heading = target.position - transform.position;
        Vector3 force = Vector3.Project(heading, railDirection);

        GetComponent<Rigidbody>().AddForce(force);
    }
}
```
