In this video, we're going to be looking at some of the mathematics you can do with vectors such as
multiplying a vector by an integer or or adding an integer to a vector or adding two vectors together.
So let's get started.
OK, so let's open our test script quickly.
OK, so we're going to make what's called a vector.
Let's make a vector two and call it position.
So if you don't know what a vector is, vectors can be essentially described as a line that points from
one position on a grid to another.
But more simply put, they are just a collection of floats, and these floats can be used to represent
a position.
If you set this to a new vector to with position five seven, this would be five on the x axis and seven
on the y axis.
There are also Vector three and Vector Force.
Now a vector for is only generally used for rotations because rotations actually rotate on four different
axes.
But generally what you will be using as a vector two or a vector three.
So they can be used to assign a scale or assign a position or assign a rotation.
They can even be use if, for example, you had a min max, then X would be usually the minimum and
Y would be the maximum.
You could even use a vector three and have the three value as the actual value, and you would use to
use this third value.
You can change these values directly by going min max dot x equals five min max dot y seven min max
dot to z equals six.
So vectors have a variety of uses.
A vector isn't actually.
A variable a vector three is actually a struct, as you can see here.
And these are all the different.
Functions that are included in a vector, you can expand these and so you can expand this and see here
Vector three Dart Forward is zero zero one and so on.
So many of the mathematical operators I taught you in the previous video can actually be used with vectors.
Let me give an example here.
So you have this vector being set two five seven six.
Let's remove this number two.
And turn no one into an end to this.
OK, so now these are all being declared right here.
This declaration right here is redundant, so we can also go print min max times number one so we can
multiply a vector by an inch.
So let's head back into our project and let's set this two, maybe three hit play.
And as you can see, it just basically multiplies each value by three.
And then returns that you can do the same thing with division and then hit play, this is divided by
three.
As you can see, it just divides the values by one third.
You cannot add an end on to a victory three, but you can add another vector three onto a vector three.
So, for example, you can multiply Vector 3.1 and this is just one one one by a number and then add
that number to this, which is essentially the same thing is adding the number one to each of these
values, and you can do the same with subtraction here, and you cannot use the greater then operator
because because any one of these values could be greater then.
But you can go if minimax sort x is greater than number one.
And then this would just check if five is greater than whatever you set this variable to.
And just so you know, you can also serialized a Vector three head into unity and as you can see, you
can just assign these values here.
OK, so that's everything for this video, and I'll see you in the next one.