Primitives Moving / Variables Varying

We’re movin’

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.

Use [SerializeField] to more easily manipulate private variables to save on aspirin!

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!

private void _playerMovement()

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.

_playerMovement() function within the void Update()

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.

Oh, I also reset the position of the cube on start to 0, 0, 0.

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!

--

--

--

If ambition and practicality amalgamated, it would be me! I am here to climb the mountains of my ambition and catalog my journey so that someone can be changed!

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Class based views are always better*

AppLibrary: A Step Towards Digital Decluttering?

How You Can Contribute to your CocoaPod Dependencies

Guide to Remove an Element From a List in Python

GitHub CoPilot — My Impressions thus far

UltraTech Try Hack Me Walkthough

Low-Code/No-Code Simplified

INTRODUCTION TO AXELAR NETWORK

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Andrew Lengen

Andrew Lengen

If ambition and practicality amalgamated, it would be me! I am here to climb the mountains of my ambition and catalog my journey so that someone can be changed!

More from Medium