 Hello guys, CryptoGrants here. Welcome back to another idle game tutorial video. This is episode 26. Today we're going to be working on the soft cap. So this might be very easy to implement, but it's going to require quite a bit of trial and error. And I might not get it perfect on my end. So that's for you to do. Anyways, it's just going to basically divide our per second and our earnings in general, and it's going to be based completely on what we have so far. Okay. And yeah, it just basically slows down progress. Okay. Okay, so what we're going to do here is we're going to start with our main screen. And in here, we're just going to add a text. So I'm going to grab one of these from the header. So I don't want to replace all the fonts and all that they already have. Set that to black or something. I don't know. And what we can do is we can give this a label. Now just remember, this is not going to go negative. This is not going to make your money go negative or anything. This is just severely slows down your progress and prevents it from going exponential like crazy. Okay. We could just say soft cap dot we could just do it could be like a tax or something like that. We could just like taxes or something like that. Okay. I don't know. You do you. I'm just going to keep it as taxes, taxes, text. Okay. Now we're going to go to our also, I'm going to fix some things because I forgot to do something. Someone commented about me having some texts like the cost update every single frame. That's a terrible idea. I agree. It's not a good idea. I just like, I just don't think about that when I, I just think about it like personally, I just forget to explain that how it's not a good practice. So stuff like this, actually we got all this done. I thought I did. Okay. But stuff like the cost, stuff like that, that doesn't need to update every single frame rate. So what we can do is have this update every time we buy something. Now this smooth number, sure that can stay. Now the thing I'm afraid of is this right here, is the smooth feel. I feel like that will not work, but we can try. So I'm just going to comment this code out and put it in our Y max, just put this here, or here we'll just make a new method called public void. Now it'll be private, it's only next to anywhere else private void, update, cost UI. Now that again, I just don't think the smooth progress bar will work. If it doesn't, then we will put that back in here. Otherwise the rest should work. And this is game about data. Okay, so we'll call this upgrade of this update cost UI in the buy max method and in our buy upgrade. Why is it still grayed out? We use this method. Okay, so I think we solved that. Basically, if you want to optimize your game, have the text update as least often as possible, like moving the cost related stuff to when you buy upgrades, stuff like that, instead of having update every single frame. Okay. Also again, changing or reducing the game frame rate to 30 FPS is all is all is also a really good option as well. Okay, so we're going to do public text Mars soft cap text or could do taxes. Okay, and then we're going to have an equation up here. I'm just going to do it could do it could be a float, but I'm just going to do big double just in case it does go severely massive. If we do go into the e 300, like 100, the 1000s, we know, never know, but I'm just going to make it as a big double. And then here we'll do Mars taxes. And we're going to set that equal. No, it's not an array. And this will be equal to game dot data. And we want this to start later on rather than so it'll be exponential too. Okay. So yeah, it's got to grow exponentially for sure. And this is going to be Mars coins. So we have a we have this right here. I think this should be a log. But the things that we need to make this log somehow grow exponentially. So if we have let me think about this. Okay, so a good way to get equations running is to just plug things in into Desmos. So let's say we have a log equation, we have an exponentially growing equation like this. Now, if we do 10 to the x, of course, it's going to be linear because it's log base 10. If we do log two, I'm not going to actually hear if we do log base to 10 to the x, you know, be steeper, right? This is the same thing as this is the same thing as 3.3333 x. I guess that's okay. So let's say we have this, this is obviously going to grow faster. But if we do to x instead, you know, it's a linear line, right? Because that's that's basically what a log is. So let's say we have our growing equation right here. And we want to do plus one. And we want to not divide by zero. So we want to add another one. So we started one. Now, if we do, let's say, let's take a really big number, if we divide this really big number by 301, you see it's not going to really do anything. So it needs to be stronger. So what if we do a square root? So if we do 10 to 300, we have this. So let's say we have this right here, right? So basically, it's just, this is just a square root of this, right? See, it's the same thing. So if we go early, you know, everything's always halfed. But I feel like that just doesn't work that way. It's still like, it's just not halfed, but the exponent is halfed forever. And I feel like that's still not a good tactic, because this needs to grow faster than the actual equation itself. So what if we have, now, let's see, this wouldn't work. Okay, so I think we're starting to get somewhere here. So as we get closer, you could see the effect is more severe, right? This is all, this is, yeah, this is literally almost a square root, right? But if we do 30, you know, the effect is not as powerful. If we do here, you know, there's, I mean, it's the same thing. This is more a half rather than, because if we do do square root of that would be 31, right? Yeah, that's right. Okay. I thought I was going crazy for a second. I was like, what? Yeah, see this, so now the effect isn't like as severe, but it grows. And let's see, let's try to get this to work. Okay, so okay, it's got a weird pause though. I think we would have to do what's zero? Yeah, we need to add the plus one or else it's undefined. Okay, there you go, that's better. You see how this is still a log, right? But this effect is severely stronger compared to doing squirt x, right? Actually, let's see, let's go further out because eventually this will surpass this. Let's see, can we find an example? Okay, I think what I'm really trying to say is that having this square root, everything be square root in the beginning is just kind of crappy. It kind of has a bad introduction to the game, I guess. And of course, we can always make this stronger or weaker, stronger, you know, this is even stronger, we can adjust this as much as we'd like to, right? This is much stronger, of course, even stronger than the square root. So this is something that you can play with. That's nice. That's what's nice about having a graph to look at is that you can visualize what's the difference between, you know, doing this or doing that, you know, you could look at the graph, obviously, you don't have to understand math to realize there's a massive difference between this and that, right? So we're going to stick to this equation. Cool. So all right, let me write this down. So we have, okay, so this is a little complicated, this is going to be a public, yeah, this is going to be a big double because we're going to hand we're handling a big double inside here. Okay, so we're going to do Mars, we're going to do Mars, we don't even have to put that where Mars on it. So taxes, exponent factor, okay, and this will equal to big double log 10. Now we don't need, yeah, just log 10 log base 10. And this will be game data that Mars coins. Okay. So, oh, I forgot, we're not dividing, right? Okay. Okay. Then we don't need this. Okay, so let's just continue this. And then we need to do, oh, we just needed this. Okay. And then we'll have POW. And this whole thing will be to the power of zero point one. And this is the thing that we can adjust, which is what I was showing in the graph earlier. And we don't need this right here. So I know how to actually like do this, it's just displaying how we're going to make this possible. I mean, obviously, I could put the exponent in the text, like this, I'll show you what it could look like. So in this equation here, or in this, yeah, in this example here, we have 0.5653, right? That's the exponent to the actual gains. So we can put now what we can do is take this original number and divide it by this number, which would be this. And then we would get we are making this much times less, or we can display it somehow where taxes are Mars coins, you know, we have this number that just looks kind of weird while we can say, you know, this large number, I guess. So I think we should stick with this route right here. So we have several equations here. I'm going to save this because this could be used in the future. Mars taxes. Cool. Okay, well, now let's apply it to the the click. So this is going to apply to the click power. Or Oh, shoot, I forgot this is different. So I know for fact, I know for a fact that this definitely works here. It's just the click thing that I'm really concerned about. Because I did I added to this equation here, which let's say our click multipliers 11, you know, 3.87 still a lot, right? I feel like we would have to like really severely decrease that or something. Maybe I can do clicks click value is this much less or something, I don't know, because I'm just doing the equation based on getting per second, right? That works perfectly fine. Let's just try it, roll with it. Don't know if this will work. Okay, so taxes will probably display this in a fancy way, less coins per second, and also minus, let's say 1.0 x less Mars coins per click, you know, we're gonna have to figure out a way to display this without looking too complicated, I guess. I don't know, I really think we're already getting too complicated. So we're gonna do how all of this one divided by exponents factor. Okay, now we have a per second right here. This is the same thing. So we're just going to do, we're going to wrap everything around here. I'm really hoping this works. I honestly doubt it will. But it'll be interesting see if it does. Okay, so now we got to do our Mars texts. And this will be the same thing with everything down here. Let's just copy what we already wrote down and text components and unity. Mars taxes dot text is going to be equal to our sign. And then we will start formatting. So this will be a backslash n for a new line. We will have our equation here. And we'll have another new line here backslash n. And we'll have our equation here. So in here, we need to calculate, we have to make such an awful equation. What have I done? So we're going to do big double taxes per taxes mult per second. Just name it whatever you want. But this will be just a better way of displaying instead of just drawing it all in the text, we're just going to have to put our method in here. Okay, so we just return. We just return without the exponent factor, our normal equation. Also, don't forget the the Mars coins per second. So let's actually grab this one. Yeah, let's do this one. And we will take this. Yeah, okay. Okay, so we'll take this equation. We're gonna divide it by Mars coins per seconds. Okay, there we go. And then in here, we will get rid of this. Yeah, that's it. Okay, we are good here, we have our tax multiple seconds, which we will need methods on notation method. And the row of the method in here. Okay. Oh, yeah, it's two parameters I keep forgetting. And up to for two decimals. And now for the click, it's the same thing, except we are going we need that we still haven't even made the equation for that. So we're going to do the second one, or the click one. And basically, it's just click power to the power of this Mars coin per second thing. So we'll take our original click power here, and we will divide it by how click power to the power of one divided by the exponent factor. Okay, and now we will start to multiply based on this instead. Okay, let's see if this works. And I should have applied it to this equation instead. That's okay, this works too. And we'll put it in here. It's not that we need the parentheses. Okay. Now I don't know if this work, this might be really weird at first. But it's worth a shot. Scaling in idle games is sure is pretty difficult because your game can either be too slow or too fast. It's hard to find. It's really hard to get right in the ballpark. Oh, so we're decreasing now. Move. Okay, that's not good. Yep, everything's in now. Beautiful. Well, this was unaffected. That's for sure. No idea why. Oh, the click power I see. The click power is just not affected. That's because of this right here. You forgot to put this in the text. Okay, now why did it do that? It's because it was based on what you currently have. And in the the per second somehow was negative. This is ugly. Okay, well, now we know that doesn't work. Okay, what's funny is that we're getting this error now because it's saying this log 10, it's using the double version of it, even though this is a big double, but that's probably because it's an NAN. Well, that's a little weird. Yeah, there we go. Okay, well, since this is frozen, can we just change it? Well, okay, well, we got rid of the NAN now. Let's get rid of all this NAN rubbish. Okay, so we escaped. We escaped it in planets, so we're okay. Now we're still screwed here. Okay. So that's weird. So the factor right now is zero, which is okay, because that means our base is one. So why is this per second NAN, though? It's something wrong with this equation, but it looks just fine. Oh, I see why it's because we're dividing by zero, or though the evil zero. Okay, I see how this is a problem now. Okay, you see here, if we have zero, this is obviously NAN, and which is why we got undefined in the first place. While we're getting undefined, now I am not quite sure. Oh, that's weird. We're getting more than what we should be getting. Well, so I think the solution is to make this equation start with one. Yeah, that makes more sense. Okay, well, let's add a one to this and it should solve all of our problems. I need to do offline progress videos. You're forgetting to do that. I just need to do it. I need to set this planet aside and just get it done. It's not that hard. Well, we started with, you see the issue here now is that we started with zero. I forgot that we need to start with one. Okay, so now you could see this decay should begin to occur later on. So if we have, let's say E3, you can see it's, you can't see the number. It's very small, but if we get a heavier E300, the multiplication is still pretty slow. Now the, let's check this out. You can see it's, it's not plus zero one anymore. It's very minimal. I think this is still too weak. Now this, okay, so at least it's not going in anymore. That's, that's a good thing. Oh, yeah, it's just very, very small. If you look right here, it's very small. Wow. Let's just put it, but why is it subtracting? I have no idea. I have absolutely no clue. I think the main issues that we're multiplying. Okay. I think that's the issue. I think instead, we need to add more coin per second, right? I think that's just the most appropriate way to do it. Because if we're multiplying something less than it, then it's going to keep going down and down and down. There's nothing negative going on. It's the fact that we're multiplying it instead of adding Mars per second or Mars coin per second. So this should work. So this is, this is already kicking in. Oh, we got to buy these upgrades. You can see yeah, this is already kicking in. Wow. So this is not what I was hoping for at all. So even if our level was literally infinity like this, this is just way too strong, I think. Okay. Well, I thought I had it based on my calculations. I'm completely wrong. All right. Well, what we can do is adjust the exponent. This is, this is, so I say it's easy to implement. Yes, indeed it is. It is easy to implement, but making it work is pretty hard. Yeah. This is pretty difficult. This is just so severe that I think we need to make this strong or not stronger, but there we go. Okay. Wait a minute. Does that work? Wait. Oh, wait. Did that actually work? Oh, that actually worked. No way. Okay. Okay. So what we're going to do, we're going to add a one on the inside right here after the log. Okay. We're going to get rid of this and this should be much better. And we can probably fix this exponent too. Cause like, I mean, it isn't going to do too much, I guess. Okay. Save it. Let's test it. Now this should be playable. Okay. This is already a lot better. Yeah. See how it's not as crazy as it was before. You know, this may take a while, but a lot less than what it would before. Also, we're getting a very low FPS because we are printing stuff like crazy. Let's get rid of this. You can see the smooth progress. Oh, the smooth doesn't even work. Yep. Okay. I knew that was going to happen. So let's just bring the smooth in here. Is this one it? Yep. Smooth fill. And put it back in here. Yeah. I had a feeling that wasn't going to work. Oh, shoot. It's a four loop. Okay. Just get rid of these. Clean it up. There we go. Okay. So obviously the coins per second is slowing down, but the Mars coins is still very strong. So we can probably nerf this because yeah, this is clearly going to, yeah, this is still too much. Okay. Because we need a place for a prestige, right? Or maybe the the intent is to make this go really fast. So your goal is to get to e308, but your coins per second is completely useless. So this is just not balanced at this point. So let's make a separate factor for click where this one will be a lot stronger. Let's see. How do we do this? Okay. So this was before. So we're the point of one was definitely a lot stronger, but then we got rid of that. So now we need to increase this. Probably not that much. Probably double the exponent. Let's try that. And we can honestly do it based on the current one. And I think these the tax text is off. Yeah, this one's not right. This is not right at all. Right. Is that? I think it is. Yeah, it's right. Okay. So hopefully this will work. If it doesn't, again, that's for me to scale. Yeah, this is still very severe. Oh my. Wow. Okay. Well, what do you know? We'll make it stronger. Again, you don't need any scaling at all. But soft capping is very difficult. Wow, it's still not working. Oh, I see why because we weren't using the click. Oh boy. Things will kick in now. Things will kick in. Yeah, I should probably do prestige soon. I'll probably do offline and then prestige. Still not kicking in. What? This text seems wrong. Yep, it is. So why is this Mars coins per second a lot faster than it was before? So I think this click is still a little crazy. Again, you need to have a prestige when people are suffering. You know, you can just have an auto clicker and beat this instantly. Yeah, see, that's a little better. But I can still buy upgrades and improve this even more. Let's see. Let's get an auto clicker. Now watch the growth. Obviously, it starts to decay. The upgrades won't beat it. So let's see our highest right now is 1.15. So if we just keep going, keep going, keep going, it doesn't stop. You're going to get to eat through it pretty soon. Probably within minutes. Yeah, see, the upgrade still beats the thing. So the kind of goal is to have the upgrade not beat the scaling system. And obviously you can make this an upgrade so let's try 0.75 instead. Now I bet it'll work. We're this close from getting it to work. So we're at like 1.16. Oh yeah, oh yeah. So now obviously this again, this is multiplicative. People are still going to be able to, you know, get through this. And also something with the text. I'm going to get rid of this minus. That doesn't really make sense. So yeah, you can clearly still get through that. Now let's try beginning of the game. So let's go back to zero upgrades. I need to fix that. Why is it doing that? Okay, I see. So in here to get rid of the NAN, just do this. So if the upgrade level, Mars upgrade level setting index one, which is our production upgrade, is equal to zero, then we're just going to return one. Okay, now we'll fix that. So let's try this now. Now it seems like we have to click a lot more. Doesn't it seem like we have to click so much more? I think we should reduce the cost of these. Okay, we'll let that auto save while we fix the cost. So I think the base cost for the first upgrade should be two. But then the cost molt should be a little higher. I think it should be like around 2.5. Oh, it's just a float we need to put the F. And that means we can get rid of this right here. Okay. Okay, there we go. See this UI, why is it not updating properly? I don't like this. It does just like a delay when you buy something. So things start to pick up now, but it's a lot of clicking. That's okay. This is mostly like a clicking thing. Again, you can add more upgrades all you want to. This is a very wimpy upgrade. But yeah, anyways, quite a mess indeed. The cost UI, we need to update on start. Okay. Anyways, I know this was a messy one. I thought it was going to be, I thought it was me a little nicer, but apparently it's not. But just know that if you want to soft cap something, just make your earnings per second slowed down based on how much you have right now. Obviously, I try to make it a lot more complex than we probably should have, but I didn't want to go crazy with the exponential growth. Anyways, hope you enjoyed this video. If you did, make sure you leave a like, comment down some suggestions below or anything down there, and subscribe if you're new. Turn on notifications and check out my videos. There's some playlists up there at the top. I'm going to click on the I icon to check out my other playlists. Anyways, thank you guys for watching. Peace.