what is a boolean

I am a noob in Unity and Ive been watching youtube tutorials and I have noticed some people use variables of tipe boolean and I cant find out why.

Boolean is a variable which can go two ways on or off :slight_smile: so you can use it for switches, to enable something or detect items such as if the player hits a location the variable switch is true and if its true do something else it usually looks like so

var <variable name> = true ;
var <variable name> = false;

:slight_smile: to detect them

if (<variable name> == true) 

note: two equal signs to say if and 1 equal sign to say it does hope this helps :slight_smile:

A boolean has 2 values: 0/1, or true/false. It’s the simplest state that a computer can represent, and corresponds to “energy is flowing/is not flowing” (all computers are built around boolean logic). Theoretically, a BOOL can be represented in memory using a single bit, but for various reasons (ease of memory addressing and speed) it’s usually 1 byte.

@Drakestar
I feel like that is so backwards if something returns a value it should be true and its numerical representation should be 1.

If something does not return a value it should be false and its numerical representation should be 0 as no value was returned and it would line up more naturally with what you’d expect.

I propose this :

bool[] realbool = new bool[]{false,true};