Objective: A break down of variables in Unity.
In my last article in simple player movement in Unity we talked about variables and how to incorporate variables in our code. Today I’m gonna give a you a breakdown of the 4 data types we will be using in Unity and the 2 reference classes you will utilize in Unity too. Now lets start with the two reference class types public and private, public allows anyone to access your class or code in unity also it is visible and can be manipulated in the unity editor . Private reference class on the other hand is not accessible by everyone except for yourself and is not manipulatable in the unity editor.
How to define a variable:
The 4 data types are integer, float , bool, string, you will use these throughout your career as a software engineer with Unity.
Data types in Unity:
Float: A number with or without decimal values, like 0.5 or 13.25.
Integer: A number without any decimal value, like 3 or 200.
Boolean: A value that can only be either true or false. Commonly used in logic or in toggles.
Another important thing when writing out your code for your variable’s is camel Casing its important that you start with the first word lowercase then Uppercase the first letter in the second word.
Example of Camel Casing: