Aiming a Gun in 3rd person

Al Heck
2 min readMay 25, 2022

--

To aim a gun, we need to use cinemachine to go to a OTS view. We also need to use layer masks. Start by creating a new virtual camera and place it in the ots perspective.

We want the transition to go faster so either change the entire cinemachine speed or add a blend for the cinemachine state.

Next, create a bool for when we aim down the camera as a parameter in the camera.

In our input manager, let’s add the aim button.

In our starter assets input, let’s add the ability to capture the input of the right mouse button being held down.

In our first person controller, let’s go ahead and send a function to our Aim in our custom controller to begin aiming.

In our custom controls, I want to set the animation aim state to true and switch cameras when we press the right mouse button.

For our animator, let’s connect the aim to the idle blendtree.

--

--

Al Heck
Al Heck

Written by Al Heck

Unity Developer and Software Engineer who loves making games with GameDevHQ

No responses yet