We learnt about if statements in unity in Ant’s lesson. If statements are used when something is conditional in a game.
An example of a situation could be if a character needed to walk on an icy surface in a game where temperature fluctuates, if the ice was cold enough he would walk, if the temperature was higher and the ice was still just water, he would fall through it.
To write an if statement you needed the statement, a condition, and a body.
This code would work in a coin toss to say out of 1 and 2, if the number was 1, you would get heads as a result.
To get tails you could write the same code and change ‘1’ to ‘2’ and ‘Heads’ to ‘Tails’.