The game we make is always seen through the in-game camera, we decide its behavior and what a final player should and can see.
The management of the camera is one of the most delicate aspects of a video game. Depending on the type of game we want to play, we create an appropriate camera behavior. It’s like a magician’s magic trick, he decides what he wants you to see and where to draw your attention.
In 3D games, the camera is usually very free, whether it’s an FPS or a TPS, so you have to be very careful with the details.
The basic behavior of a camera is to follow the player always keeping the same distance, one of the easiest ways to do this is to insert the main camera as a child of the player and place it at a distance that seems optimal.
This solution is not the only one possible, but it is certainly the fastest if we are talking about a three-dimensional game in the first person or third person.
Through the code, it is necessary to manage what can be the limits of rotation of the camera and the sensitivity of its movement. Playing first-person games I preferred to divide the sensitivity into two separate variables so that I can independently modify the sensitivity of the vertical rotation from the horizontal one.