Variables! — The Building Blocks of Programming

A variable is like a lump of modeling compound. *evades mentioning a brand name* You give it a name and define its shape. You can use it in your code, and when you change its shape, the code just accepts its new form!

Variables come in different types; here are a few:

  • int // an integer (a whole number like 5, 0, or -100,000)
  • float // a decimal number (5,066.75, -0.667)
  • bool // a Boolean; must be true or false; used for logic
  • string // Anything you can type with a keyboard: “Hello, world!”

There are more complicated ones too: A Vector3 is three floats together, and can be used to represent a point in three-dimensional space (an x, a y, and a z coordinate). You can store components of game objects, or even game objects themselves!

When a certain turtle-smashing Italian plumber grabs a magical mushroom, his sprite renderer variable is changed from “small plumber” to “Super Plumber!”