 In this episode, I'm going to be teaching you guys everything about math related to idle games, and I'm also going to be showing you how to code them properly, and I'm going to show you the difference between the big double math equations and the traditional ones, for those who don't plan on using big double. Hello everyone, it is Crypto Grounds here. Welcome back to another Unity Idle Game tutorial video. This is episode 2.2, and today I'm going to be showing you some math stuff. So if you enjoyed this video, make sure you smash the like button, subscribe to my channel if you're new, turn on the bell for future notifications of videos and live streams. And if you want to support me, check out the links in the description below. Anyways, let's hop right into it. So first of all, let's just hop on the Desmos. So Desmos is a really good site to graph equations. I use it a lot when I plan out how I want equations to grow in my games. So I have a bunch of equations here. So what I'm going to be showing you guys is linear. I'm going to show you guys some square roots. I'm going to show you guys polynomial stuff or powers. I'm going to be showing you some exponential stuff. I'm going to show you guys some logarithmic. Gosh, I hate saying that word. I'm going to be showing you guys some logarithmic stuff. Yes. And yeah, so I'm going to start with linear. So linear, obviously, is just a straight line. There is no form of growth. It is just a constant linear straight line. And it just goes on forever. Now just a good basic example for using in a linear equation would be, for example, clicker heroes, like how many enemies you have to kill in order to move on to the next stage, just something simple like that, like it increments five every stage. That's basically just how it works. So it's just a straight line, really, really easy. Okay, so square roots are good for prestige formulas. They're probably the most common related to those. But it basically it's a curved line. How it works is the same thing as x to the power of a half. So like this, you can have a format like this, or you can have the square root symbol. And I'll show you guys how to do this in the code later on. But it's basically just a curved line. And instead of linear, you know, it grows slower. So yeah, this is good for diminishing returns. And we'll prevent your game from blowing up from a crazy prestige. So polynomial equations are really good for costs. So just basic costs like upgrade. Okay, so next is the exponential equation. So this one you got to be kind of careful with because if x is too large, it'll pretty much explode. But basically, this equation right here is telling us that for every x, y is going to be doubled. So if we do two to the power of two, it's going to be four. If we do to the power of eight, it's going to be 256. So it goes really fast. Okay, so now for the log. So log is basically the inverse of this exponential equation right here. So if you look at it, it's pretty much the same shape, just flipped over the x and y axis like that, which is really cool. So basically, instead of growing super fast, and now it slows down much faster. It's just like a square root, but it slows down just much faster. It's like it's almost a straight line. So these can be good for some prestige equations, or some boost that you want to diminish very fast. So now the one thing I know about logs is that you got to be careful setting this log to zero because you know why it doesn't exist. It's undefined. So now this will produce an NAN in your game. And that is a big no, no. So if you're using boosts and stuff, and you know that your currency, your x right here is going to be zero at some point, just do a plus one. Okay, just as a safety precaution. So now if x is zero, you know, this log equation right here is going to be equal to zero. So it won't be an issue. It's just when this whole thing in here is zero. That's where we have this issue. We have the undefined. We don't want that we want to stay away from that. Alright, so that's log. Remember, it's just a very sharp diminishing returns. Okay, so another example of this is 10x and just log x. So now log by itself is already log base 10. So this is log base two. And remember, it's just the inverse. So this would technically be the same thing as log base 10 log x. Okay, that's the same thing log base 10x log x. It's the same thing. See if you turn this on and off, if we have just log x, you could see that it's just the same thing here just turn on and off. So now you could see that the higher the base is, the sharper the curve is, same with the exponential growth, the sharper this the higher this number is, the faster it's going to grow. So now this one is basically going to multiply by 10 for every x while this one's only two. Fun fact, this is actually how the exponent is calculated with scientific notation. It's basically just a log x. So if you do, for example, 10 to the power of 20, you're going to get 20. Okay, it's very simple to understand. Alright, so now we have all the equations set. If you guys have any questions, make sure you leave them in the comments below, or you can just take a good Google search, or you can check out Desmos and play around. I'd actually really suggest you guys to do that just mess around here for a little bit just to get the hang of it and just see what math does. Okay, so now in our controller script, I have created a bunch of equations here, you guys don't need these at all. But again, if you want to play around, go ahead. But basically, I've explained earlier that big double is different than doubles. So if you're not using big doubles, you're going to be using these. If you're using big double, you're going to be using these, and maybe the sometimes. Also, I just forgot to replace these right here. Oops. This is the linear equation. It's just going up by x here, except we're multiplying by five. So it's just a straight line. So it's just five times the number. And that's just linear growth. Now right here, this is the square root one. Now there's two different ways I showed you the two different ways here. So all of these equations I made here are in the script, just in exact order, just a heads up. So you can do big double dot square root, or just squirt like that. And that will be for the big double square root stuff. And this is good to go here. Now you can also just do big double dot pal, and just do your number to the power of 0.5 exact same thing. Now you would already be familiar with power right here, because this is the polynomial stuff right here. So basically your number to the power of two. So this is your polynomial equation here. And right here, this is your exponential one. So instead, it's two to the power of number. It's the same power method right here. Now for the log right here, it's just big double. And then you have a number in your base here. So right here, this number is the base. When I say log base two, I'm saying this is the two right here, the base is two right here. Now log base 10, that is this right here. Okay, so now big double actually has a built in log two equation. So you can just simply do log two, and then just put your number in here. Now however, if you're going to do specific bases like 2.5, you must do the regular log here, you can't do log 10. And then your number 2.5, it doesn't work that way. log 10 is basically log. And then the base is 10. Okay, so this right here is the exact same thing as this right here. So you can do however you want it'll show perform the exact same thing. It's just this is much shorter. So this is the exponential big double equation. Again, this is just the same thing as this. This is the inverse of this equation. And yeah, so this is all the big double equations. So now for all your folks that aren't using big doubles here, or you have double variables that you want to do math with, this is the exact same thing as above, except that you're using the system dot math class instead of the big double one. Now this is important because you cannot use a big double on a double variable. Okay, you can use math on a big double variable, but you can vice versa. So these are all the exact same things. I don't need to repeat what they all do. So anyways, guys, I hope that was understanding and I hope that you guys learned something new today. If you guys did make sure you smash the like button, leave a comment below on your opinions on this video, and suggestions and all that good stuff. Make sure you subscribe to my channel if you enjoy this content and if you're new around here, become a part of the crew, turn on notifications for future live streams and videos. If you want to support my channel, I would highly appreciate it and you should check out the links in the description below. Huge shout out to all my patrons and my YouTube members. You guys are the big reason why I am still here today. Anyways, guys, I'll see you guys in episode 2.3, which will be me explaining how to use arrays and how they work. And these will be very, very important for the future. Anyways, have a great day night and I'll catch you guys in the next one. Peace.