Unity Basics

Understanding Vector3

An interactive 3D visualizer. Drag the sliders, watch the arrow move, and see how X, Y, Z coordinates work in Unity.

Click & drag to orbit · Scroll to zoom

Vector3 Values

X (Red) 3
Y (Green) 2
Z (Blue) 1
Multiply 1.0x
Presets

Vector Operations

See how vectors combine and transform.

Magnitude (Length)

How long the arrow is. Calculated with the Pythagorean theorem in 3D.

sqrt(x² + y² + z²)

Magnitude: 3.74

Normalize

Shrink any vector to length 1, keeping the same direction. Toggle "Normalize" above to see it.

vector / magnitude

Multiply (Scale)

Multiply each component by a number to make the vector longer or shorter. Use the Multiply slider above.

Vector3 * scalar

Add Two Vectors

A ( ) + B ( )
= Vector3(3.0, 4.0, 0.0)

Vector3 in Unity

Unity uses Vector3 for almost everything — here's how.

+

Position

Where the object sits in the 3D world. (0, 0, 0) is the center of the scene.

// Move to a specific spot
transform.position = new Vector3(3, 2, 1);

// Move 5 units to the right
transform.position += Vector3.right * 5;
R

Rotation

Euler angles — how many degrees the object is rotated around each axis.

// Rotate to face a direction
transform.eulerAngles = new Vector3(0, 90, 0);

// Spin 45 degrees on Y axis
transform.Rotate(0, 45, 0);
S

Scale

How big the object is. (1, 1, 1) is the default size. (2, 2, 2) is double.

// Double the size
transform.localScale = new Vector3(2, 2, 2);

// Stretch on the Y axis only
transform.localScale = new Vector3(1, 3, 1);

Common Vector3 Shortcuts

Unity has built-in constants so you don't have to remember the numbers.

Name Value Use Case
Vector3.zero (0, 0, 0) Origin, reset position
Vector3.one (1, 1, 1) Default scale
Vector3.up (0, 1, 0) Jump, gravity direction
Vector3.down (0, -1, 0) Falling, ground check
Vector3.right (1, 0, 0) Move right
Vector3.left (-1, 0, 0) Move left
Vector3.forward (0, 0, 1) Move forward (into screen)
Vector3.back (0, 0, -1) Move backward

Ready to use Vector3 in a real game?

Follow our step-by-step Flappy Bird tutorial and put these concepts into practice.

Flappy Bird Tutorial