 Hello guys cryptic ground to your walk up back to another unity bolt video today We're gonna be making an idle game in this episode to today We're gonna be adding upgrades for our click and production and if you enjoyed this video Make sure you smash a like button comment all your feedback suggestions all that good stuff below and subscribe my channel If you're new and turn on those notifications for future live streams and videos anyways, let's just hop right into it All right, so I made two buns here real quick I'm gonna expand Yeah So I made a click button that increases the effect by $1 for when you click and Has it displays the cost here as well, and I also made a production upgrade. Actually, this isn't proof. This is just production money production and We're just gonna do Plus $1 per second, okay, and we also display the cost here, too I also just added a money per second text because I won't obviously be able to determine how many Or how much money we're getting per second Okay, and now let's go into our script editor. So We put our script right here in main in the game object main and you see this flow machine here We're just gonna click on edit graph. Okay, and it should open up a window mine Just popped up on my other monitor and we are back where we left off So before we actually start doing this, I let's make a variable real quick We need to have several variables. We need our upgrade level and our Yeah, our agreement level for both of these and honestly, we can make a money Temporary variable for money per second and the cost for these so we can worry about that later So what you do here is just type in a new variable name. We're just gonna do click upgrade one level hit enter And we're gonna set the type to int. Okay, and we're gonna do the same thing for production upgrade one level And we're gonna do the exact same thing as an int And I wonder can you make a Test let's see. Can you make an array? Let's see. That'd be kind of cool. I Don't think you can make it raise Okay I'm sure they'll have that at some point Alright, so let's just create some visual stuff first. So we're gonna do our Coins per second so we did the exact same thing here as we do for our coins text So let's see. I haven't done this in a little while. So we're gonna add a text dot text Okay, and we're gonna do sets Alrighty and We're gonna set the text component to our coins per second There we go, and now we need to input a string and this Needs to update as well. So we're gonna drag the update event node into our text node like that Oh, I see. I forgot about this You actually have to do it right after this one It's a bit weird Yeah, like that Can't it's the one thing I really don't like because you can't have multiple nodes, I guess I mean it actually makes sense. No, I think about it. Never mind scratch what I just said. I Want to drag this to All right, so now we're gonna start setting the string So we need to bind this dollar sign into here So the thing is that we can use this for multiple cases not just one So if we re-re-drag this it will also create another node so we can use this twice Just so we don't have to keep reusing the same dollar sign prefix so we're gonna have that here and we are going to add a variable and We will be doing the ad components Takes forever to search Okay, and math generic like that And we will add this to a and we're also gonna drag this output into the string right here Alrighty Let me just bring that right here I know some people won't be very happy with this criss-crossing thing that I'm doing Organize it honestly doesn't really matter Yeah, I'm just gonna you can deal with it like that that looks fine So we have our dollar sign, but we also need to display the money and the per second So we actually have to do another string. So we're gonna add another unit and we're gonna add a string String literal and we're gonna set this to per seconds actually it's space per second Alrighty and we are going to join these at the end So I'm gonna put this right here Organization is also very key when it comes to this So we're gonna make a temporary variable. We're gonna add a float Okay Float literal here and equal to whatever the money per second is and right now that's just whatever this level is So we also need to get a variable sort of add a unit Get variable. Oh Yeah, we do get money per seconds. Can we do that? Money per No I guess we could just change this so anyways, we're gonna. Oh, right. It's the production level So we're gonna get this production upgrade one level right here and we basically just gonna set that to All right, that doesn't work that way This is a bit weird. I think I might add another group. Okay, so we have this right here and And That's pretty much what the the money per second is right now But when we have to multiply other upgrades together I will have to do like the add multiply another stuff, but for now, it's just an individual upgrade So we're gonna bind the dollar sign and upgrade together So drag this node into the b-node for add it like that And then after this we're actually gonna delete this one right here Because we need to add the per second at the end So we're gonna add another add we actually do string interpolation Okay, anyways, we're just gonna add the add component here And we're gonna drag this into a and then the per second right here Into b like that Alrighty and now we're gonna set this to our string for the text And we can organize this a little bit. This might be a little difficult to achieve This isn't the very neatest flow chart you'll ever see But it's okay. It works Like that. Okay, so now our coins Our coins text should work I also want to do some formatting So I'm gonna add a float to string Float to string Format okay And we're just gonna set the format to f2 as well Same thing as this and now we're gonna drag this green into the blue node And get rid of this one And then this orange one into the ad right here like that Yeah, this is getting a little messy already And now we should see zero points zero zero per second by default Uh, let's skip that a try real quick. So we're gonna save it And run it Cool. So yeah, now we have two decimals and it says zero dollars per second All right, so now we need to do the upgrades real quick And I'm just gonna create another group by holding down the control and just dragging And now this is exactly the same as the click method right here We're just gonna create an on button click event right here And we need to assign a button which will be the click upgrade one right here So we can just drag that or we're beginning to select it from here But I think it's easier to drag At the beginning it may be easier to just click here because so you have less options to choose from if that makes sense Well, yeah, I also want to read in this to click upgrade Oh, I want to see can you make a switch switch Interesting let me experiment with this. So I guess there really is no way to do switch case for this That's okay Yeah, anyways, we're pretty much just doing the exact same thing here. So we just need to add a set variable We can also just set the Set level and get our click upgrade one level here. That's a nice thing. You can actually search for that makes it a little easier Um, direct this green arrow into the other green arrow right here And we need to get variable Um, no, we don't we just need to add by one Oh, yeah, yeah, that's right. We need to get variable because we're adding on to it So we're gonna get click upgrade one level and We need to get an int literal and we need to add a component Alrighty, now we have our format here like this Also, I could space this out a bit like that Okay, now we're going to drag this a plus b into this one right here And we're set this into toe one. We're adding my one And dragging this get variable and to be So now we're adding one to the original level and setting it equal to what the level actually is Alrighty, so now we need to actually subtract the cost and we also need to make the cost too And I think that's a little tricky So this is why I like programming better is because this just gets a little tedious and you do more work than what it should be Instead of just typing one lines, you know what I mean But anyways, we're gonna do the cost Alrighty, so what we're gonna do here is create Um, we can actually just get this variable from here Yeah, so we can use this to get our cost here But we do need a float and this is our multiplier here I wish you could name them, but I'm gonna use a 1.05 107 Alrighty, and now we need to have a multiply We also All right, so what we're gonna do is normally it's 1.07 to the power of the level So we're gonna drag this green node right here and add it to the power And float will be set to the to the f right here the number or the base Okay, and now we do 1.07 to the power of level And now after this we can multiply the base Times the the exponent here Like that also it looks like I need some kind of flow Right here, which is interesting because an ad doesn't so Not really sure why this requires some form of flow I guess this kind of makes sense. We can just do this here All right, so we're gonna connect to this the set variable here Oh, wait, we actually need to do the cost before then so I don't like you need a point for this exact reason. It's very like over complicated Alrighty, so let's delete this right here Connect the on button click to this POW method Alrighty, and I'll honesty at the end this makes a little bit of sense Alrighty, we'll do our math related stuff here. All right, so we're gonna have our cost right here We need to subtract it from our money. We also have to do some checking too. So We need to create new statements I don't know how this is gonna work. Whoops I think what I do is that I create a bull I don't know what this this is weird. Hold on. I'm gonna figure this out All right, so we actually have this greater or equal then so this is pretty much just an if statement here So now what we're gonna do is check to see if our currency our money Is greater than or equal in the cost. So that would be B Oops like that All right, so what we can do is either drag this node into the a slot right here And that looks kind of messy Or we can just add a get money component right here and just simply add it right here And just drag this gray node into a so it's whatever you want Now it looks like we have some issues here. I think it's related to the flow And can I distract this here? Will that work? No, that doesn't work Alrighty I think this is grayed out because we never actually do anything with this greater or equal then So this is a bull right here because it's purple. So now we need to determine if it's uh If it's true or not and I think we use I think we use this a select Yeah, we use a select But I don't know what this means. It's true or false. I think we can either indicate if it's true or false Um, I'm just gonna drag this right here um Okay, I see I'm looking in that image. We actually use something called a brand Um, so we're gonna add a branch component And here we you'll see our Our purple thing here and it returns a true or false right here This is getting kind of messy I'm gonna bring this back over here. I know that isn't the greatest. I know you OCD people are gonna are gonna Go crazy and now we're gonna drag this this um this green arrow at the math f dot pow And attach it to the green arrow in the branch and everything should be fine here So now we need to determine if it's true or false if it's false, then we're just gonna ignore I think you can ignore right or do we return? I think we just do nothing. So we can just leave that empty And if it's true, then we're gonna attach it to the set variable right here But we also need to subtract the cost first before we actually change the level because of this cost right here So We need to subtract the cost from This right here, which the nice thing about this that we can drag this to a whole new area up here So we're going to Um, we need to actually subtract. Okay, so we're gonna subtract Alrighty, but before we subtract We have to actually set we have to actually get the variable Okay, we're doing the exact same thing here. We grab it in Grab this variable all that stuff. So we get the level. Ah, it's a mess. I know So But we need to subtract the cost or the money from the cost. So that's a from b. So money is a So luckily this is close. So I'm just going to drag this money components into a oops And then I'm going to subtract I'm going to drag this a times b right here and put it into b So luckily they're both very close. It's just I'm kind of need to space things out of it So we need to subtract um Money from this. Okay, that looks fine And then I think we just set it to the cop. We set it to our current money Let me get a little closer. You can't extend this unless you're really close And Set click upgrade one cost. Oh, I know we set money. Yep. It's correct Alrighty Finally we set money Equal to this a minus b here We also need to attach this This arrow right here For the true into money right here the set variable like that Alrighty It's going somewhere guys And now we can finally add this green arrow To the set right here now again, this looks kind of ugly. So you can either move this A head like that, you know, you can just put it wherever you want honestly So now We have a huge mess And anyways, what it should do is that I should actually On when you click the button you should grab the cost Determine if it's greater equal than if it is then we're going to um Grab the cost right here And subtract it from Or yeah, we're going to have money and subtract it With the cost here And then we're going to set that we're going to replace our current money with it That's a lot. That's a lot of gibberish. Okay Let's just see if this works first before we like dare to begin with the the production upgrade But also we want to set this replace this float with this click upgrade one level So I'm going to delete this component right here And add a git Click upgrade one level And just replace it here and we're good like that All right, so let's save And let's give this a shot. It's a risky one Okay, so currently we get Zero per click and that's because I forgot to actually add one to the level All right, so what we're going to do here is just add. Oh, what did I do? Okay We're going to add one And this Oh, I think we just right click here. Yeah, we're going to add one in this variable together And then replace this A node with A plus B like that Alrighty, also another thing we didn't do is set the Is that the the text here? We'll get to that Okay, so now we should get one per click And now if we upgrade this it doesn't subtract Oh wait, this one right here. Okay, so now we get two per click Nice and it's also increasing the cost. So that works very well. Also, you can look at the the flow chart here You can see it run in action. You can see everything is running. Oh, that's so satisfying Cool. So everything seems to be running great What's our current level? 18 Yeah, okay, so we also need to replace all this UI and we'll do that So I want to update this UI not on update, but honestly just Um, we want to start doing things efficiently So I want to update this click text whenever we buy this click upgrade and on start And obviously it's zero. We don't have any saving date saving loading and that's honestly something I'm afraid of So do we have player prefs? Oh, we don't that's kind of sucks Um, anyways, we're just gonna set a text dot text Okay. Oh, let's get we don't want to get Okay, and we're gonna do sets We're pretty much just gonna set it to click plus dollar sign. Okay, so that's very easy So we're just gonna add a new string a string literal And we're gonna call this click backslash n Plus dollar sign. Okay, so that's a prefix and we're gonna add We're gonna add this And the current level Okay, and we're also gonna have to like create some variables and stuff in the future Where it's multiplied by other stuff. So it'll also be a little easier to Manage I guess but this is just gonna become a huge And if this isn't efficient and you're really good at unity bolts, you can make fun of me all you want I'm a noob But anyways, we need to get a click upgrade one variable Like that And we will set it to be you know add a plus b and set it to the string right here for text We also need to add this um This flow right here Like that Oh looks like we're missing something What happened there? Oh right here. Okay. That was weird. Um, basically replace the self with the The click text so click button text right here drag it into the text box right here And now we can finally add this green arrow to the flow right here I'm gonna move this up and organize it a little bit. Oh, yeah, we've got to Readd a plus b to the string right here And now on start it should show Um plus one per click. Oh, yeah, we gotta add All right This is where it gets a little tedious and honestly I could probably just grab this a plus b right here Let's do that. I mean, I don't really care about how messy things are. I can just move this here Instead of doing extra work here We'll just drag this a plus b and put it into here right now Okay, and that looks Like it'll work It's we're pretty much doing the exact same thing We're just not doing we're just doing less work instead of just having to make this all over again right here And I also want to make a little box right here for start And I know a lot of stuff is gonna happen here at some point So we also need to attach a flow here To make sure this runs Um, I want to say something. Can we add another? A road here. Oh, we can. Oh, that's sick. That's sick Okay, I mean that would be kind of silly if you couldn't But after we set this variable here since this is the last flow We're going to grab this green arrow And attach it to this one right here. So we're updating the text whenever we buy this upgrade And I'm going to show you how this works In a second All righty So Oh man, are you serious? It actually does back It actually does that That is stupid Okay, I've tried experimenting this with this for a while and You need each the unity discord is full of bots and don't want to answer me Seriously, so I'm just Do everything on one line which kind of sucks But I guess this is how we're gonna have to do it because you can't do a new line with strings And I guess a multi-million dollar company just doesn't want to implement that So I have to just have to wait for a future update or Uh, I don't know I made a tweet. So hopefully they'll see it I doubt it. Maybe add it soon. I don't know why they haven't yet I don't know So I guess we're kind of stuck with this So anyways, we're just going to do click Plus that much it looks ugly, but it's fine Um I think today I'm just going to do the click upgrade just because this is a lot of work And I'm a little stressed over the fact that you can't do a new line So Anyways, we need to have this button do something too So Um, let's just start this in here Actually, yeah, let's just add the text in here So the cost is right here. So I think I'm gonna add it right under here Or in here. Yeah, I'm kind I'm kind of deciding where I want to put this Alrighty, so we're gonna add another set text right here Okay, I like when this happens Okay, that was weird. You have to zoom in. I don't like that. It's a little weird Um, we're gonna set this text to The click upgrade one text right here Okay, and we're gonna set the string to several things. So we're gonna have an improve click And stuff like that So let's add another string Okay, and this is just gonna be Um Click plus one One dollar again. We can't really do anything fancy here because unity And I guess we'll just put a dash cost Dollar sign, I don't know. I don't like this And we need to add them together Okay, so this would go into the a And b will be the actual cost, which is what is right here for the multiply. So we'll put this in b And also actually before we do this I want to have a a formatter. So we're gonna add a string New string and we're gonna do um Oh, you know, it's just format, right? Yeah string dot format Which one did I actually use? Oh, it's two string, right? Okay, so we're gonna add a two string here And this is a float A float to string Format yep And now for a format, we're just gonna do f2 Actually, I want to do n2 All righty, and we're gonna drag our a times b right here into this blue Float slot right here and drag the orange and two hour b right here And we're gonna add them together and set it to our cost text So now this will be ran whenever we actually, uh Buy this upgrade, but we also need to add this flow right here Okay, oh man, I forgot you can only add it once so we need to This is a bit trashy Okay, so we're gonna drag this arrow here and drag this one from this text all the way back up here All right, that works Not as efficient as I'd like but it works Okay, so let's save it and give it a shot Also, it still says this at the start so we might have to move this anyways Uh, okay Let's buy that. Okay now should show the correct one It doesn't show the correct cost though It shows the cost afterwards. Okay, so that's kind of an issue So it shows the previous cost Okay, so the other way is the display is fine It's not the end of the world. It's just that it's displaying the wrong one Okay All right, so what we're gonna do so since it's grabbing the wrong text We actually need to make this cost again Um, I don't really know a better way to do this for now other than just redoing this not really redoing this but Um doing it again I know this isn't very Yeah All right, so we're just gonna copy all this again And this is basically just calculating our next Next click upgrade one cost That's fine with me and basically we just take this flow right here Um, so let's get rid of this right here Get rid of this flow right here. Basically, we want to drag this set variable here into the pow And then we want to set it this one to the text right here and now we Format this great this um We actually don't need this right here. We can get rid of that This get variable here I don't think we need this either Yeah, we don't need this I think we're missing something though. Oh wait, we're not this f right here is Oh, we're missing the power. Okay. I was wondering what we're missing here But we get that p from the Get variable here. Okay, so we're gonna add this right here Actually, we can just replace this one here get rid of that node um Set this give variable to the click upgrade one level right here and set it to the power Alrighty and now we get rid of this greater equal then And drag this a times b into this formatter They shift everything here Right here into the blue And now it should work as planned Oh, yeah, we want to drag this over in play mode shoot That's not good. We can't do this all over again. Hold on Alrighty, so what I did is that I kind of reorganized it So make sure you connect this set variable to the power here And set this pow to the text right here. So we're setting it I also dragged this um this original text right here Into here instead of recreating this whole costing over and over again I or I really don't want to do that so I create I just Drag this green arrow right here into the power right here So now we have two green arrow connections going into this So hopefully it works and obviously this is very confusing and I'm going to put this out here the series is not going to be long at all because I'm going to get very stressed with this I might just do the improve and that's it Maybe prestige and then I'm done This is very tedious. Okay, so it looks like it didn't work So Let's see do it. Does this even get called? Um, oh, it looks like there's an issue here Right here. So this will prevent the future code from running Um, we can get rid of this a plus b. I don't know why I still have that Like that. Okay. So now we're just doing click colon plus dollar sign put that into a And we grab our one plus level Into our b and then we add a plus b and set that as the string Alrighty, let's get by the shot Cool. So it runs everything correctly. The cost is 10. So let's see if we keep playing 10 70 so the next one should be 10 70. Yep. That's right. Also, let's look at the satisfaction right here Ooh, look at that. It's so satisfying I think I'm done with this. This is quite a A mouthload of stuff to do The video actually turned out a little shorter than I was expecting Anyways guys, if you enjoyed this video, make sure you smash that like button Subscribe to my channel if you're new and turn on notifications for future live streams and videos Comment all your suggestions questions feedback all that good stuff And anyways, have a good day and night and thank you guys for watching. Peace