There were a few keywords we were introduced to in the beginning of Unity which were:
- Variables – These are the containers for the information you want to store in your scripts.
- Data Types – These are the different types of variables that you can store different types of information.
- Functions – A block of code comprised of many statements that is used to achieve a specific task.
We were also introduced to IF statements:
- IF statements are used in scripting to test if a statement is true or false. If the conditions meet our requirements then a specified task will be executed. For example: If <enemy health is less that 1> then <destroy enemy>
- IF ELSE / ELSE statements are used in situations where you also want something to happen when your conditions are not met.
- It is possible to test multiple statements using the “AND” and “OR” operators. There is also a “NOT” operator for testing when something is not true.
As you can see on the example shown above theres something called a public variable, there are three types of variables like this within scripting and they are public, private, and protected but we only really use public and private. These control who sees the scripting within the section:
- Public variables, are variables that are visible to all classes.
- Private variables, are variables that are visible only to the class to which they belong.
We also have something called 'void Start' and 'void Update', these mean two different things to anything scripted within them. Anything within 'void Start' only happens during the beginning of the game, and anything within 'void Update' is called once per frame so is repeated throughout unless told otherwise.
No comments:
Post a Comment