A variable stores a value that can be used or changed while the program is running.

Basic syntax

int health = 100;
float speed = 5.5f;
bool isAlive = true;
string playerName = "Player";
char rank = 'A';

Common Unity types:

Vector2 position2D;
Vector3 position3D;
GameObject player;
Transform target;

Expose a private field in the Inspector:

[SerializeField]
private float speed = 5f;

Constants cannot be reassigned:

const int MAX_HEALTH = 100;