Looking at the Player in Unity

This tutorial will cover always having the camera look at the player and track the player as they move across the screen. First create a new script called LookAtPlayer. Add the script to your main camera.

In the script you will not need the start function so you can delete that. Add a transform variable that will reference the player. Then in the update script call transform.LookAt and pass it your player variable.

// Update is called once per frame
void Update()
{
transform.LookAt(player);
}

Make sure you assign your Player to the player variable in the Unity editor.

That is all you need for your camera to stay focused on the player as they move about the level.

-Chris

--

--

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