void Awake() { gameManager = FindObjectOfType <TTGameManager>(); mainCamera = Camera.main; cameraController = mainCamera.GetComponent <CameraController>(); controller = GetComponent <CharacterController>(); // Is this the localPlayer if (isLocalPlayer) { localPlayer = this.gameObject; gameManager.localPlayer = localPlayer; cameraController.target = transform.Find("Camera Target"); } Debug.Log("My starting position: " + transform.position); }
void Awake() { // Check if instance already exists, if not set instance to 'this', if instance is not 'this' destory 'this' if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } customOps = FindObjectOfType <NetworkManager>().GetComponent <CustomOperations>(); spawnPoints = FindObjectsOfType <PlayerSpawnPoint>(); txtBawesomeness.text = "Bawesomeness:"; if (playerPrefab == null) { Debug.LogError("<Color=Red>Missing</Color> playerPrefab Reference. Please set it up in GameObject 'Game Manager'"); } else if (PlayerController.localPlayer == null) { Debug.Log("<Color=Green>Player Instantiate</Color> We are Instantiating LocalPlayer from " + SceneManager.GetActiveScene().name); // Default spawn point Vector3 spawnPoint = new Vector3(0, 30, 0); // If array of spawn points exists, choose a random one if (spawnPoints != null && spawnPoints.Length > 0) { spawnPoint = spawnPoints[Random.Range(0, spawnPoints.Length)].transform.position; } Debug.Log("<Color=Green>Spawn Point chosen: </Color>" + spawnPoint); PhotonNetwork.Instantiate(playerPrefab.name, spawnPoint, Quaternion.identity, 0); } Debug.Log("<Color=Green>Awake() for TTGameManager</Color>"); }
void Awake() { gameManager = FindObjectOfType <TTGameManager>(); }