Objective: understanding what method parameters are and how to use them.
Method parameters are variables you can set inside the parenthesis.
These can be any types of variables. We can even use these parameters to change an objects color using parameters.
To begin you need to make a game object variable.
Create a void method with the parameters of a game object and a color.
When you call on this method you will need to use a game object and a color or else the method can’t be called.
We will need to use the game object parameter and use get component to gain access to the mesh renderer and change the color to the color parameter.
Now when you start the game you game object will change to the assigned color using parameters. You could use an input method if you want to control the color change with a button. To do that you would put an if input function in the update method.
Now your game object will change to the assigned color with the press of the space key. This is a simple way to use parameters. You could also use parameters to assign values, or you could use parameters to create a damage function. Don’t be afraid to experiment with your code, and I’ll see you in the next tutorial.