Camera not following after respawn

So I’m not sure how I could have done this wrong, all that’s being done to fix this issue is to destroy the gameObject which I’m doing.
I’ve had a little play around and if I I start in Scene 1 and transition to scene 2 and die there, the camera does follow me when I respawn in town but I respawn at the transition point (I didn’t set up new portals in the town scene as I don’t play to publish the game). But this is because we have the SetPlayerCameraFollow method set up on the area entrance - nothing to do with destroying the player.
Obviously I could just call that from PlayerController start but I’m wondering what I’ve missed that destroying the player just makes this work in the tutorial but not for me.

I’ve poked around in the repo and can’t find anything (but gitlab doesn’t have a code search like github does :frowning: )

I’m honestly not sure, as the only references I could find to CameraController’s SetPlayerCameraFollow() are in the CameraController itself, and within the AreaExit.

using Cinemachine;

public class CameraController : Singleton<CameraController>
{
    private CinemachineVirtualCamera cinemachineVirtualCamera;

    private void Start() {
        SetPlayerCameraFollow();
    }

    public void SetPlayerCameraFollow() {
        cinemachineVirtualCamera = FindObjectOfType<CinemachineVirtualCamera>();
        cinemachineVirtualCamera.Follow = PlayerController.Instance.transform;
    }
}

When the game reloads, I’m finding that the camera properly locates the player within the game, but as I go through the code, it really shouldn’t be…
Of course, the best fix is, indeed, to add a call to SetPlayerCameraFollow() to PlayerController.Start() which should resolve the issue.

Privacy & Terms