Working with Cinemachine

Learning how to switch cameras

Now it is time to apply what we have learnt through practical application. In this article we will explain how we can swap an 3rd person camera to an Orbital camera via script just like how professional games do it.

Prepping the Cameras:

First we are going to create two new Virtual Cameras and named them 3rdPerson and Orbital.

For the 3rd Person Camera we are going to set up the follow to be the player, and the body to be the 3rd Person Follow. Freely Adjust the Shoulder Offset according to your player height. (In my case, I have a cube representing as a player)

For the Orbital Camera I need to setup both the Follow and Look At to be the player, while the body is set to the Orbital Transposer.

Creating the Player:

For the player we are going to create a cube and add in another cube for arms and head for definition purposes.

Then we are going to add an Character Controller so the player can move around a bit.

And finally a custom script which will control the character controller and also the Camera movement.

Scripting:

The Script is going to be named “Character” and it will control the player movement along with swapping the camera from 3rd person to orbital when you click the Right Mouse Button.

Then we are going to create two new methods called Movement, and Switching Camera.

For the Movement we are basically going to access the Default Unity Input system.

And for the Camera Swapping Method wear going to use the Set Active function to run on and off the camera whenever we press the Right Mouse Button. By using an Boolean we are able to swap between states and still use the Right Mouse button as the Trigger.

The end result would look something like this.

--

--

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
Simon Truong

Simon Truong

A Designer, an Illustrator and a massive tech geek aspiring to become a professional Unity Developer.