The basics of basics - Variables

Timo Schmid
2 min readApr 5, 2021

--

We have the following objective:

The objective

The objective is to create various variables for different types of data which we’d like to store in the program.

As variables are usually declared with a private access modifier, we will add a [SerializeField] attribute for the data type, in order to make the variable visible in the Unity Editor.

A name is usually a string of letters. Therefore, we need the data type string:

Age, health, score and current Ammo are usually full numbers. That being the case, we will need the Integer (or int for short) as the data type:

The speed variable can be either as full number or not. Therefore, it would be best to use the float data type. Even if we are using a full number.

haveKeysBeenCollected is a question. For this, we will use the bool data type. The question can either be true or false.

The end result

--

--

Timo Schmid
Timo Schmid

Written by Timo Schmid

The mission? Becoming a game developer! RPG is the dream! Writing down my journey here for me and for everyone interested. Thanks for showing interest :)

No responses yet