AI Features

Variables

Learn about variables and how they are used to store and manipulate data of different data types throughout the code.

Introduction

In Unity, variables are used to store values that can be used and manipulated by our ...

int score; // here, 'int' is the data type and 'score' is the name
float speed; // here, 'float' is the data type and 'speed' is the name
string playerName; // here, 'string' is the data type and 'playerName' is the name
bool isJumping; // here, 'bool' is the data type and 'isJumping' is the name

Initializing variables

Variables can be initialized with a value when they are declared. An example is given below:

int score = 0;
float speed = 10.0f;
string playerName = "Player1";
bool isJumping = false;

Using variables

...