I didn't think about parenting the camera to the FollowCamera object

Instead what I did results in pretty much the same, but instead in code.

What I did is get the offset between the camera and the anchoring object (the FollowCamera object which I placed at the scene’s origin), and inside Update() apply this offset to the camera’s position as well:

public class FollowCamera : MonoBehaviour
    [SerializeField] private Transform followTargetObject;

    private Transform mainCameraTransform;

    private Vector3 anchorOffset;

    private void Start()
        mainCameraTransform = Camera.main.transform;
        anchorOffset = mainCameraTransform.position - transform.position;

    void Update()
        transform.position = followTargetObject.position;
        mainCameraTransform.position = transform.position + anchorOffset;


I changed the setup according to the lesson’s solution.

One thing though: Assigning the player in the scene and then applying the override on the FollowCamera rig doesn’t assign it inside the prefab (and it shouldn’t). The assignment is still just in the scene and as long as there is only one scene that isn’t an issue.
Later on when there will be more than just one scene, this will need some changes. Moving between scenes will need more than just this one anyway…

Privacy & Terms