© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2024
C. HardmanGame Programming with Unity and C#https://doi.org/10.1007/978-1-4842-9720-9_37

37. Mouse-Aimed Camera

Casey Hardman1  
(1)
West Palm Beach, FL, USA
 

Before we give the player any means of moving around, we’re going to provide them with a first- and third-person camera system that lets them turn their character and camera with the mouse. Both systems will be handled by one script, and the player will be able to press a hotkey to smoothly switch from one to the other.

Coding the first-person camera will be a bit simpler. We position it where the player’s eyes would be, and we rotate it based on changes in the mouse position. Move the mouse left, the camera ...

Get Game Programming with Unity and C#: A Complete Beginner’s Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.