3rd Person Controller Using Cinemachine Virtual Camera On Mobile

Let me share my approach in having a 3rd Person Character Controller using Cinemachine FreeLook Camera with mobile Input.

[YouTube] https://youtu.be/mqC2XXKkcMg

[GitHub] https://github.com/rehtse-studio/Cinemachine_MobileInput

I’m not going into detail to explain how the UI (FreeLookCamera_UI) works since is the same one I used in my previous article.

The PlayerWithFreeLookCamera object has the script called PlayerControllerWithFreeLookCamera and the PlayerInput component form the New Input system.

The PlayerControllerWithFreeLookCamera script has two key differences in the inspector from the last article. This script only has a reference for the Joystick Input from my UI joystick, in the last article I needed reference to both the look input joystick and empty GameObject called CameraTargetObject inside my player that was doing the rotation

What is the difference?

The difference is that this time I am not using a Virtual Camera, I’m using Cinemachine FreeLook Camera. The FreeLookCamera, that is inside my player, comes right out of the box and has a 3rd person camera view. The FreeLook Camera will Follow my Player’s GameObject and is using the empty game object inside my player to be “Look At”, without it it goes crazy.

Inside the Players Controller Script

PlayerControllerWithFreeLookCamera script has the same code from the last article, the only key difference is that I do not need to tell in code how the camera will move or at what point it need to stop on the rotation since that is done in the Freelook Camera Rigs, the only thing you need to do is to calculate the players movement depending on the rotation or the forward of the camera.

Passing My Look Input To The Free Look Camera

In order to make my Free Look Camera move acording to my touch input on the screen, I need to create a new script call CinemachineMobileInputFeeder

The CinemachineMobileInputFeed is the one taking the look input reference from my UI touch panel. Using Cinemachine namespace I have access to overwrite where the FreeLookCamera get the input.

At the beginning of the article you have links for the Unity project and the video from YouTube.

Hope it helps.

To be continued 😎



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
Rehtse Studio

Rehtse Studio


Game Developer sharing content around Unity, programing and tips and tricks in game dev.