Objective: Create a camera sensitivity variable and organize the inspector!
In this tutorial we are going to create a variable to control the camera sensitivity. As it is the camera movement to mouse movement is not ideal. With this game type being a shooter, we want to have more camera movement to mouse movement, or at least the ability to choose.
We begin by opening the player script and we need a float variable for the mouse sensitivity. We serialize it so we can adjust through the editor.
From here we navigate to the method that controls the camera movement. We are going to multiply the mouse input by the mouse sensitivity variable.
Now you can run your game and find the right sensitivity for you.
While we are talking about variables in the inspector, we can add headers to the inspector to help organize the layout. We have variables for the player and variables for the camera. Adding headers will help quickly navigate the inspector.
To add a header, in the player script we use the bracket and the keyword header. Using a string we name the header.
The header needs to be above a variable that is visible, or it will not work.
Now we have created mouse sensitivity and cleaned up the inspector! Keep coding and don’t be afraid to experiment with your scripts. I’ll see you in the next tutorial!