Camera! Follow Me!- Game Dev Series 92

Objective: create a following camera by using Cinemachine.

We have used Cinemachine virtual camera to make some cutscene. This time we will use it to replace the game camera to follow Player.

In this article, we will set a Cinemachine camera as main camera and adjust the rotating issue of Player.

Start with virtual camera

Create a virtual camera into scene. If you have no Cinemachine drop down menu from the top, you may install it from Package Manager.

Adjust the camera in Inspector. Drag in Player gameobject to “Follow” and “Look At” to make sure Player is the only target.

We can also adjust some value under tab “Aim” to present a better angle.

Rotating issue

However, if you play the game in this way, you might see this.

The camera also rotate when Player has rotated. Because we make camera follow Player but we rotate the whole gameobject of Player when turning around.

To fix this, we can simply adjust the rotation only on model gameobject. That way the facing of Player gameobject would never change.

Create a gameobject variable in Player script, and use it to replace the origin rotate gameobject.

And now camera would perfectly follow the Player.



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
S.J. Jason Liu

S.J. Jason Liu


A passionate gamer whose goal is to work in video game development.