Camera doesn't follow

Not sure what I am doing wrong but the camera does not follow my player anywhere. I tried to follow along as best as I could.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FollowCamera : MonoBehaviour
{

[SerializeField] Transform target;

void Update()
{
    
transform.position = target.position;

}

}

1 Like

For this style of camera, the Camera should be looking at the FollowCamera GameObject, framed the way you want it, and the the FollowCamera should have the Player’s transform dragged into it.

I changed that but it’s still the same. I made the Camera a child of the FollowCamera and changed the transform, no change.

I am concerned that if I don’t fix this I can’t proceed with the tutorial?

Can you paste in a screenshot of:
The heirarchy with the Player, the FollowCamera gameobject and Camera
The Inspector for the FollowCamera

Select the FollowCamera and paste a screenshot with all of the components opened.

It looks (from the Gizmos display of the Camera’s frustrum) like the Camera is at the position of the Follow Camera… I’m guessing the transform of the Main Camera shows a position of 0,0,0…

Here’s the best way to set the follow camera up:

  • In the Editor, put the FollowCamera object at the same location as the player
  • Now with the Main Camera set as a child of the FollowCamera, adjust the camera so that the player is centered in the Main Camera’s view, at the angle you’re wanting. An easy way to do this is with the Main Camera selected, adjust your scene view so that the player is where you want it in the viewscreen. Then (with the Main Camera selected), from the main menu select GameObject | Align With View
1 Like

Thanks that solved it. Exactly what was wrong?

The camera just wasn’t set in the right starting position.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms