0

Share

GAME DEVELOPMENT

How To Make Cinemachine Camera Follow The Player?

  • Home
  • Blogs
  • How To Make Cinemachine Camera Follow The Player?

Cinemachine is a camera system that works in a way to create complex behaviors without writing any code and gives AAA quality controls for every camera in your project.

Agnesh Pipaliya

June 28, 2022

Introduction

The Name “Cinemachine” is a modular suite of camera tools for Unity which give AAA game quality controls for every camera in your project. It’s an easy to install plugin which lets you add functionality to cameras you’ve already got, or make new ones with amazing behaviours.

NOTE : Cinemachine is used for many purposes but here we only make this demo for player following Camera not for other purpose.

 

 

In most cases all developer who does not know use of cinemachine, they use old past method to make camera follow the player as shown in the above image.

How To Make Follow Camera Using Cinemachine

Do First:

Create new empty project.

Set game view aspect ratio 16:9.

Download project from link and open it in your current project.https://github.com/Brackeys/2D-Shooting

Find the scene name with “main” and open it.

Go to asset store and import Cinemachine package in your current project.

Step 1: Add “Cinemachine Brain” Script To Main Camera

Find Main Camera in hierarchy and click on add component button in the “Inspector” and type “Cinemachine Brain” to add Cinemachine Brain script to the main camera.

 

 

Step 2: Create Empty Game Object To Organize Cameras

Now I wanna create a new empty game object just to organize my cameras, so I will call this “cameras”, we will reset the transform, because we may add some other virtual camera that we can drive around as part of this process.

I will drag main camera down under cameras, and there we have it. See below image.

 

 

Step 3: Create Cinemachine 2D Camera

Okay, so let’s create our first Cinemachine. Go to Cinemachine > Create 2D Camera.

 

 

Step 4: Assign Parent Game Object To The Cinemachine Camera

After click on “Create 2D Camera”, you will see one object with the name “CM vcam1” available in the hierarchy.

Now I'm just going to parent that underneath cameras I’ll show that under the cameras.

 

 

Step 5: Give The Reference Game Object To The Follow Camera

Okay, so we’ve got our first virtual camera, now drag our player to the “CM vcam1”>Cinemachine Virtual Camera(Script)> Follow.

 

 

 

 

Step 6: Some Important Notes:

Okay, so our camera follower is partially ready.

Important Note:

Our camera only see within the blue portion as shown below image.

The red portion indicates the camera doesn't able to view that portion.

Here in your project you will see little yellow dot as shown below image is indicates where the camera is looking at the moment that’s the middle reference point of the camera.

Rectangular space made by four white aero as highlighted in below image is the dead zone, if we increase the dead zone width, we can run within the dead zone and the camera doesn't move at all. It’s only when we get to the edge of the dead zone, we have a bit of a follow.

 

 

Step 7: Set The Camera Properties

Make sure, you have selected Framing Transposer. If you have not selected Framing Transposer, you might not see all that stuff.

 

 

Step 8: Check The Property Change Effect On Player

Change the value of “Body” like X damping, Y damping, Dead Zone Width, Dead Zone Height to Zero. You can see our camera is locked directly on the player, and that’s okay if that’s the sort of game we’re making. Your gameview looks like this below image.

Run the scene and you see it feels very jarring, particularly when you jump if we turn down the dampening which says how fast the camera is gonna follow player up and down.

 

 

But if add little bit X and Y damping and dead zone limit as shown image,

 

 

Then you can see it takes a while to catch us and then if we increase the Dead Zone Width, then the camera start follow after player rich edge of the dead zone. The dead zone is reasonably good as well, you can play around with this.

 

 

That is the fundamentals of having a follow camera and getting that amount of play and dampening and dead zone that you like.

Conclusion

This step-by-step guide is helpful for your project to develop a follow camera using Cinemachine. And after development, you can easily observe how effective it is for your game development project.

img

Agnesh Pipaliya

COO of Vasundhara Infotech, a leading Software development company in the USA. His technological interests has helped the company in making useful decisions.

message

Have a project in mind? Drop a message to Bansi Pipaliya & start the discussion!

Get a Newsletter

Sign Up to our newsletter to get latest updates staight in your inbox.

Vasundhara respects your privancy. No Spam!

Get a Newsletter

Sign Up to our newsletter to get latest updates staight in your inbox.

Vasundhara respects your privancy. No Spam!

message

Have a project in mind? Drop a message to Bansi Pipaliya & start the discussion!

Latest 13 Web Development Trends To Expect In 2022
April 11, 2022 Category : company news

Revealing Vasundhara’s New Identity

Read More
Latest 13 Web Development Trends To Expect In 2022
May 17, 2022 Category : web development

Latest 13 Web Development Trends To Expect In 2022

Read More
Leave a Comment