We’re moving through Vector space! How?
Through variables varying!
What is a variable? The simplest way I could put it is anything that has been given a set of values. Variables are also able or apt to vary. Variables be varyin’.
So for us to get our little pink (it’s color is up for debate but I see pink) cube moving we need to define some variables: how fast the cube gets to go and what our inputs are going to be, then we mix those together and we’re scootin’. We first need to understand the Concept of Variables!
As you can see in the image above there are 3 required components to a variable with 1 optional. You always want to start out by defining if the variable is going to available outside of the script or not: public or private.
There are also 4 common data types (there is also “char” which is essentially a string but just one character). So let’s display our variable for how fast we’re goin’!
So the main question I asked myself is… “Why the f is there a “f” needed at the end of the float?”. The reason I found was that if there was no “f suffix” then it will be considered a [double] and [double] cannot exist in a float similarly to how an integer cannot be used in a string. So we’ll do what the language tells us to do and move on to movement input!
So here I have created what is called a function or method, they both mean the same thing, which is essentially allows me to create a pocket of neat code to plug-in where it would make the most sense.
So since we’re dealing with inputs we want to run our function within the [void Update();] parameters! Why? [void Update();] is constantly running, and we don’t want our character moving inconsistently.
Well, we’re movin’ and I learned a lot. Now it’s just a matter of keeping it down and using it over and over! I’m excited!