Switching between Gameplay Cameras

Cinemachine and Timeline Final Framework Log 4

Dennisse Pagán Dávila
3 min readDec 13, 2023

I’ve previously discussed a variety of camera types, mostly inclined toward having a humanoid player character rather than a large object like a spaceship. Since I have talked about third-person cameras at length, this project update will be more concerned with showing the thought process behind adding a virtual camera for a large object rather than demonstrating the ins and outs of how the camera functions. Let’s get to work!

Table of Contents

· The Importance of Choosing Camera Parameters
· Switching Camera Views
The Result

The Importance of Choosing Camera Parameters

When it comes to a 3rd-person spaceship view, we have to keep in mind the kind of gameplay that will be possible and just how big of a field of view we’ll need to allow the player to have the most advantageous and/or enjoyable experience. In my case, my project is more cinematic in nature without the need to have over-the-top flight controls or super-actiony maneuvers.

As such, the 3rd-person camera has been added with just enough distance for the particle effects of the exhaust to be noticeable. If the project were to become more gameplay-dense, I may opt for a more distant view to make room for all the action on the screen.

Switching Camera Views

I want the player to be able to switch between a first-person camera and a third-person camera. The first-person camera will give us a view of the ship’s interior at the cockpit — this area has its own dedicated post-processing and reflection probes to differentiate from the atmosphere on the outside.

This can be achieved by manipulating the priority level of the virtual cameras via code. Here we use a foreach loop to set a low priority for each virtual camera.

Then we create a function that assigns a higher priority to identifying the current active camera.

Note: The camera that has the highest priority will always be our active camera or current camera.

Lastly, we register the user input so that each time a key is pressed, our current camera number will change and our functions will act accordingly so we can cycle between the two views.

The Result

Here I am pressing the R Key to switch between camera modes

I hope you have found this information valuable! Follow me for more Unity Development articles! :) I am a passionate Unity Developer and Writer on a journey to join the video game industry. Check out my LinkedIn and Twitter!

--

--

Dennisse Pagán Dávila

Software Engineer that specialize in Game Development. Currently looking for new opportunities. Portfolio: dennissepagan.com