 In episode 3.3 I'm going to be showing you guys how to create an automatic upgrade unlock system which requires you to reach a certain point in order to unlock certain upgrades so such as this I'm going to reach 25 flash and we're going to unlock the next upgrade just like that. Hello everyone it is Crypto Grounds here welcome back to another Unity out of games tour video this episode 3.2 and today we're going to be doing the unlock system for our upgrades so how this is going to work is that upgrades are just going up here on the screen when you reach a certain point so you can kind of have the unlocking the unfolding mechanics I guess you could say and this is very easy to do it's just a few lines of code that we're going to be doing if you end up enjoying this video make sure you leave a like to support the video if you aren't subscribed already make sure you hit that subscribe button and turn on the notifications for future notifications of videos and live streams so anyways what we're going to be doing is heading to our upgrades manager script so in our upgrades manager you can see that we have created click upgrades and production upgrades so these belong to the object upgrades so we don't have let's go to our upgrades real quick so you can see that we have our upgrade button level name and cost so our upgrade button we can assign an image to this and turn it off or we can actually just turn off the game object of this object so we're going to do that instead and that would just be reducing the amount of adding we have to do what we're going to do is create two big double arrays so this would be click upgrades unlock we'll do the same thing for production and in our start method we will assign whatever number we want our things to unlock at so let's say we want the first upgrade to unlock immediately we can just have that at a zero so we're going to create new big double array and we're just going to set the first one to zero because we want to see that right away and our first upgrade it's cost is going to be 50 let's make that 25 and then the next one will be 50 and then the next will be 500 so I'm basically doing half of what the original cost is you can simply do 990 or 40 if you'd like so you can do whatever you want with these but I'm just going to do half of the original base costs and I'm going to do the same thing for our productions upgrade deluxe and except I'm going to be adjusting these two whatever I want all right so here our two additions inside of the update method we're going to be looping through all of the upgrades inside of our list so to do that we're going to be making a for loop so we're going to start at zero and we're going to go to the click upgrades count and we're going to increment i by one and now to access this we need to do click upgrades at index i and we're going to turn it off on and off by doing that game object set active and for our set active we're going to pass in through controller dot instance dot data dot flask is greater than equal then click upgrade unlock at index i so now basically whenever our flask is greater than the cost the base cost it's going to turn it on so the current issue with this is that it's going to keep turning on and off whenever our flask is not or is greater than this unlock so we want to make sure we want to keep it on when it's on so what we do here is if our click upgrades at index i dot game object dot active self so when it's not active already we want to check to see if we can make it active and we'll do the exact same thing for our production upgrades awesome sorry if this is really slow I don't know why writers lagging like crazy now obviously if you had more upgrade types to do you could you can make a method for this and just keep these separated but we only are doing it twice so I think we're fine so one thing we notice is that these are all on so when we create our upgrades right here they are turned on by default and that means this will be ignored entirely so we actually have to turn these off before we do this so let us do that so in our start upgrade manager we're going to head to our for loops here we're going to add a line in here we want to turn off this game object after we instantiate it so we're going to do upgrade dot game object dot set active false and we're going to do the same thing for the other for loop and we should be set so now you only see one upgrade which would be the click and the one flash per second so let's get some flash going and there we go we had the second upgrade and we could do the same thing there we go we got another one and I think the next one unlocks a little further down the road but you get the point anyways guys I know that was really simple and I hope this is useful for some of you guys who are interested in this if you did enjoy this video and you found it helpful make sure you leave a like share with your friends subscribe to my channel if you aren't already and turn on the bell for future notifications of videos and live streams thank you guys so much for watching all the way through I will see you guys in the next one in episode 3.3 and this will be on generating upgrades so this is kind of like anti-matter dimensions if you haven't heard of that game you basically have units or upgrades producing each other so this will be kind of an interesting topic to discuss and it will require some expansion have a great day night everyone and I will see you guys in the next one thanks for watching again peace