Camera Look System in Unity and Cursor Locking

Now that we have our player moving and the camera moving with the player, let’s take a look at how we can make a couple adjustments to that camera movement. To start, let’s get to work on creating a way to adjust the sensitivity of the mouse. First, we will quickly add a sensitivity value to our camera’s rotation method:

With this particular method, we are multiplying our movement values. This can allow us to also create a slider in the future for players to move about depending on their comfort zone to play with. Now what we will do is create some logic to hide and lock the players mouse cursor while in the game:

What this Locked code does is once the player starts the game, we will have the cursor locked and hidden on the screen. From here, we will need to create a method in which we can unlock the cursor so that if we what the player to be able to interact with menus, we have a visible cursor to make it easier on the player:

As Escape is usually the key game use to open up a menu to exit games, we will have it set up so that we will unlock our mouse to let the player move it around. With this in place, let’s take a look to see how it looks within our game:




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Schedule task with WorkManager: An Android Jetpack Library


Re-thinking Claims

Best Java EE Frameworks Tools in 2021

Fun with Skybox’s in Unity

AppSync Lambda Authorizers Via New Amplify Custom Resources

Design patterns. Decorator in examples

cs371p Spring 2022 Week 11: Badr Belhiti

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jordan Evans

Jordan Evans

More from Medium

Make Player Move with Platform in Unity

Asset Bundles for Unity

Creating MineField In Unity (Part 1)

Did you just hit me! — Hitbox attack system in Unity2D