Make the Main Camera Look At the Player.

Look at the player all the time during the game.

Objective: Create a script to make the camera look at the player.

Create a new C# Script called LookAtPlayer and assign it to the main camera.

In the script we have to declare a variable of type Transform to store the player transform. Then in the Update method we have to use the function transform.LookAt() and pass the player transform as a parameter. The LookAt function is going to readjust the camera to look at the player all the time.

And that’s it!!!! Our camera follows the player perfectly.



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
Rusben Guzman

A Software Engineer passionate about game dev and interactive products with Unity. I consider video games to be the artistic expression of programming.