We'll come back.
And this video I want to introduce classes to you that we have not used yet, but that we can use.
And in general, I want to show you that there are classes which you can use in order to have functionality
that you don't have to write yourself.
So one thing that is used very regularly, which is very important in most of the video games, is a
random factor.
You need to have some sort of randomness sometimes in order to make the game fun because it's unpredictable
what happens next.
And if you want to do that, you don't have to write the random functionality yourself.
You can simply use a class which is built in into C-sharp or in this case into unity.
So there is a different type of this random class that unity uses.
So let's go with random.
So what it does is class for generating random data.
So there is a class called random.
And if we press the dot button, we can see the different methods and the different properties that
this class has to offer.
So for example, it has to offer a range with this or a range method.
What this does is it returns a float value, which is a random value between a minimum and a maximum
value that you can assign yourself.
So if I do that, for example, let's go ahead and I say I want to have a value between zero and 15.
So I said float min is zero and float max is 15.
And what I want to do with this is I want to save it in a variable, so let's save it in a float, my
random number, and now let's print that out.
So backlog my random number.
Now doing that in the start method is great, but doing it in the update method is maybe a bit more
interesting.
So let's do that.
Let's create a new random number every single time and let's print it on the screen and it will create
loads of random numbers.
So let's just have a look what that does.
All right.
So there we are.
We get a random number regularly already, 100 and so many numbers.
So let's pause the game.
And as you can see, the number that we get is 11.6, 6.3, 9.1 and so on.
So I get numbers between zero and 15 and they are completely random.
Well, at least there is random as a computer can create them.
And that's quite some randomness that we get here.
And that's a functionality that you might use very often based on the games that you want to build.
Now, another thing that you might want to use is the math class and the math class.
In this case, it's a strict math F and the struct contains a collection of common math functions.
So let's have a look at the math.
If we press the dot, we can see all those properties and methods.
So here we have apps that if you want to get an absolute number across coziness, if you want to have
a arc cosine of f well plenty of math methods.
These are quite useful if you want to do something with angles.
If you want to change the angle or calculate the angle, then if you want to round something down,
you could use floor.
If you want to use the exponential, you could use x, p and so forth.
So you can see you have all the different methods in here, pow, syn sine, smooth step, all those
kind of things.
So I'm not going to go through all of them just for you.
So you know that there is something that will make your job a lot easier.
So this is what I highly recommend whenever you're in a situation where you think, All right, well,
I want to do A, B, C, is there a way to do that easily?
So don't try to write complex, highly complex code.
First of all, check out Google.
Just have a quick look.
Maybe you can find something, do some research before you do hours of programming.
All right.
So the math F function, for example, is very powerful to help you with whatever has to do with math.
And there might be classes that I'm not covering in the course which will be very useful to you.
So always have a look at which classes are available and which can help you based on the situation that
you're at.
All right.
So that's it for this video.
Please check out the math class, check out the random class, use them, try them and see you in the
next video.