Trying to get Camera to spawn at Base

I just finished the lecture Camera Movement and am trying to get the camera to spawn above the base.

I saw another Ask about it and that helped a little bit, but the camera still starts on some corner of the screen. Here is my code:

private void Start()
        UnitBase[] bases = FindObjectsOfType<UnitBase>();
        for (int i = 0; i < bases.Length; i++)
            //if (bases[i].connectionToClient.connectionId != connectionToClient.connectionId) { break; }
            if (!bases[i].hasAuthority) { break; }

            playerCameraTransfrom.position = new Vector3(bases[i].transform.position.x, playerCameraTransfrom.position.y, bases[i].transform.position.z);

I am still understanding things like authority and how exactly to call it, and where to call things, so any help would be appreciated!

Hi Mason,

Are you calling this in the start() method of the Camera Controller? It could be that it is getting called before all the unitBases are spawned.

I used the unitBase event ClientOnBasedSpawned to trigger the camera location being setup, so that I know for sure the unitBase is created before moving the camera in place.

Hmm that sounds like it could work! I’ll give that a try later and see, thank you!