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());
            }
        }
    }
예제 #3
0
    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());
    }
예제 #4
0
 private void Awake()
 {
     I                = this;
     _camera          = gameObject.GetComponent <Camera>();
     _debugProjection = DebugProjection.ROTATED;
 }
예제 #5
0
 void Start()
 {
     multiTargetCam = GetComponent <CameraMultiTarget>();
     multiTargetCam.SetTargets(targets);
 }