Objective: Change the Security camera color to red when the player is detected!
As it stands, the cameras will be panning slowly until they detect the player. When the player is detected the camera is going to stop panning and in half of a second the game over cutscene will be detected. We want to turn the color of the camera from its standard color to a red when the player is detected. To do this we need to begin with creating a handle for the camera’s mesh renderer.
With the mesh renderer connected we want to set the color using RGB values. Create a variable to hold the color we want to change to.
Some colors only range from 0 to 1 instead of 0 to 255. To convert our RGB values, divide the values by 255 and round to the first decimal point.
Since the shader on my camera is Legacy Shaders/Particles/Additive the name for the has to be “_TintColor”. This is because the color on the inspector is under the Tint Color.
Now when the player is caught by the cameras they will stop rotating, turn red, and after waiting half a second initiate the game over cutscene.
Those are all the functions we wanted our cameras to have. Don’t be afraid to experiment with your own cameras, they don’t need to be carbon copies of mine. I’ll see you in the next tutorial!