Scale a GameObject up and down in size - 4


English (Auto-generated)

So in this cast will work on the toggle scaling function and like we discussed in the previous cast that a toggle scaling function is responsible for starting and stopping the object from scaling. So it contains within itself those conditions. So let's go ahead and declare void. A toggle scaling function like so. And then let's just also put a comment here. So end of a toggle scaling these closing comments. Just help to manage your curly basis so that you're not making syntax errors. The first thing that we'll do is we'll invert the value of the should scale bullying which is currently true. So let's invert that and we want to do should scale is we can do false or we can even do this which is basically saying not should so not should scale is also false. Right? It's the equivalent of just using the false boolean data type. Now, next we want to write and if conditional statement like so so let's structure that. So if should scale variable is false. Right then what do we want to do? Well then we want to reset the objects local skill to the max scale and we'll see transform dot local scale is equal to Vector three variable max scale. Okay. And we also want to reset the alpha 20 and after that we will also set the is scaling up bullying to false since the object will be at max scale and we'll have to scale down when should scale is true, right? So out here you'll say is scaling up, variable is also equal to false right? Since we're already at max scale, once we reach at max scale, we cannot further scale up, which is why we we've set this as false control. S and then let's see if we are getting any errors. We are getting some errors. Let's see where we are getting that error. Okay, yep, so in between here I forgot my curly braces and let's go again. Okay. Right, so this is just a warning. But well basically when we work on the update function, this will no longer be there. But so far we are okay, there are no errors but three object is still not updating. Still not, you know, scaling up and down. And the reason is because remember we have now all these functions we have scale up scale down and toggle scaling functions but they are not being called anywhere. And where will we work on them? Well, this is where we are going to be working on calling these functions and we'll do that in the next cast
112 Views 0 Likes 0 Comments

ToggleScaling() function

Leave a comment (supports markdown format)