# Vector3

> Creates a new vector with given x, y, z components.

## Definition

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

## Vector3(float, float, float)

Creates a new vector with given x, y, z components.

```csharp
public Vector3(float x, float y, float z)
```

### Parameters

**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): **** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): **** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)):&#x20;

### Examples

```csharp
//Attach this script to a GameObject.
//Attach a Rigidbody component to the GameObject (Click <b>Add Component</b> button in the Inspector window and go to <b>Physics</b><<b>Rigidbody</b>)
//This script moves a GameObject upwards using a Vector3
using UnityEngine;

public class Vector3CtorExample : MonoBehaviour
{
    Vector3 myVector;
    Rigidbody m_Rigidbody;
    float m_Speed = 2.0f;

    void Start()
    {
        //Set the vector, which you use to move the RigidBody upwards straight away
        myVector = new Vector3(0.0f, 1.0f, 0.0f);
        //Fetch the RigidBody you attach to the GameObject
        m_Rigidbody = GetComponent<Rigidbody>();
    }

    void Update()
    {
        //Move the RigidBody upwards at the speed you define
        m_Rigidbody.linearVelocity = myVector * m_Speed;
    }
}
```

## Vector3(float, float)

Creates a new vector with given x, y components and sets z to zero.

```csharp
public Vector3(float x, float y)
```

### Parameters

**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): **** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)):&#x20;
