Camera Follow System in Unity
3rd Person Zombie Shooter
Objective: Camera follow the mouse cursor
First of all create a crosshair using the canvas image.
Inside the player script, create a variable to reference the main camera and a float variable to adjust the camera sensitivity.
Now reference the main camera to the created variable inside the Start method so that it is referenced at the start.
Now create a new function to control the camera behavior. Inside it, create a reference float variable to store the value when mouse moves up/down and left/right. Then rotate the camera along the y-axis to look left/right and along the x-axis to look up/down. Since we are making a 3rd person controller, make sure to clamp the camera rotation so that camera doesn’t rotate too much and has player in its view.
Now call the function in the update so that it is continually being called and it works.
And this is the final result.