public GameObject addPlayer() { GameObject target = GameObject.Instantiate(playerPrefab, spawnPoints[0], Quaternion.identity); cameraMultiTarget = Camera.main.GetComponent <CameraMultiTarget>(); //target.GetComponent<MeshRenderer>().material = materials[currentPlayerId]; target.GetComponent <PlayerController>().playerId = currentPlayerId; target.GetComponent <PlayerController>().cameraTrans = cameraMultiTarget.GetComponent <Camera>().transform; currentPlayerId++; return(target); }
void Start() { cameraMultiTarget = GetComponent <CameraMultiTarget>(); targets = new List <GameObject>(); if (playersInGameSO.playerSphereTransforms != null) { GameObject[] alreadyExistingTargets = cameraMultiTarget.GetTargets(); if (alreadyExistingTargets.Length != 0) { foreach (Transform sphereTrans in playersInGameSO.playerSphereTransforms) { if (sphereTrans == null) { continue; } visualsPrefab = sphereTrans.gameObject.GetComponent <SpawnCharacterVisualsPrefab>().GetPrefab(); //Checking if the visualsPrefab is in the array if (Array.Exists(alreadyExistingTargets, x => x == visualsPrefab)) { targets.Add(visualsPrefab); } } cameraMultiTarget.SetTargets(targets.ToArray()); } else { //If the camera doesn't have any targets yet, we don't need to check for duplicates, //and can directly pass all the targets foreach (Transform sphereTrans in playersInGameSO.playerSphereTransforms) { if (sphereTrans == null) { continue; } visualsPrefab = sphereTrans.gameObject.GetComponent <SpawnCharacterVisualsPrefab>().GetPrefab(); targets.Add(visualsPrefab); } cameraMultiTarget.SetTargets(targets.ToArray()); } } }
void Start() { players = FindObjectsOfType <PlayerController>(); example = FindObjectOfType <CameraMultiTarget>(); var targets = new List <GameObject>(players.Length); ExampleGameController.instance.setSpawnPoints(); for (int i = 0; i < players.Length; i++) { players[i].enabled = true; if (players[i].cameraTrans == null) { targets.Add(players[i].gameObject); players[i].cameraTrans = Camera.main.transform; } players[i].gameObject.transform.position = ExampleGameController.instance.spawnPoints[i]; } example.SetTargets(targets.ToArray()); }
private void Awake() { I = this; _camera = gameObject.GetComponent <Camera>(); _debugProjection = DebugProjection.ROTATED; }
void Start() { multiTargetCam = GetComponent <CameraMultiTarget>(); multiTargetCam.SetTargets(targets); }