### Scale a GameObject up and down in size - 3

##### Transcript

English (Auto-generated)

Hi everyone in this cast. We work on two functions to scale the tree, game object up and down in size. So we're going to do this here after the update method. And let's declare a function called scale up so wide a scale up and this is our function and we can have and just a comment. So end of scale up. Okay, so we're going to be using a vector three and once again, so let me just type this out. So what we're doing out here is a vector three, A new scale. So we are declaring a variable called new scale, which is going to reference a vector three variable and this is going to be better three dot loop. And then it takes as arguments, the mean scale, the max scale retreat. Already declared up and alpha. And then we are going to transform on local, it's a local scale is equal to new scale. Oops, absolutely. Okay, so vector three dot loop gives a vector three value between two vector three values. Depending between two vector three values. Yes, depending on the alpha or which we already discussed is a range between 0 to 1. So it can be zero or 0.5 and or it can be one Right now, the variable. New scale refers to a value that we get by interpolation between the main scale and the max scale using alpha. And then we're going to be setting the three game objects. Local scale to the value of the new scale variable, which is a vector three variable. Now, just to go through this again. local scale is the scale of the transform relative to the game objects apparent and this is the scale up function. Similarly, we're going to be working on the scale down function which is almost the same with one exception, so void still down. And then once again, let's just end of the scale. Let's just put a comment here, scale down. And once again out here we have a vector three variable new scale. But this time a new scale is going to be a bit different. So vector three dot ler again and this time we have the max scale, then we have the min scale rates of record, mean scale and lastly RAFA. And once again it comes from local scale is equal to the value of a new scale variable. So once again we've declared a variable called a new scale by interpolation between the max scale and the main scale using alpha. Now, the difference between a scale up function and scale down function is out here. The max scale goes first and then vector min scale variable is a second in the order of arguments. Right? And once again, we've set the trees game object to the scale to the value referenced by this new scale variable. Okay, so I'm just going to control safe and come back here and always making sure there's no errors. If there is an error, the script won't compile and will tell you out here. So this is a warning. It's not an error error is going to be in green. Sorry, red. Okay, so we can see that right now. Three game object is not scaling up and down in a size. So next, what we have to do is we have to toggle the scale up and scale down functions. And what this means is that when the game starts, number one, the tree is going to be scaling up and down in size automatically. But if we press a key on the keyboard, when the tree is scaling up, then it should stop scaling. And if the tree is not scaling in size and we press on a key, then it should start scaling up. So what we're going to be working on next is a function called toggle scaling. And this function is going to be responsible for starting and stopping the tree game object from scaling.
9 Views 0 Likes 0 Comments

Let's work on the ScaleUp() and ScaleDown() functions