public virtual void OnSpawn(SpawnPoint spawnPoint) { }
public void SpawnPlayer(SpawnPoint spawnPoint, bool reset = true, bool nextFrame = true) { StartCoroutine(SpawnPlayerCo(spawnPoint, reset, nextFrame)); }
public SpawnPoint GetSpawnPoint(string name) { return(SpawnPoint.Find(name)); }
IEnumerator SpawnPlayerCo(SpawnPoint spawnPoint, bool reset, bool nextFrame) { if (nextFrame) { yield return(null); } Profiler.BeginSample("SpawnPlayerCo"); lastPlayerSpawnPoint = spawnPoint; if (!playerPrefab) { Debug.LogError("Missing player prefab"); yield break; } if (!playerController) { playerController = Instantiate(playerPrefab); } if (!playerCamera) { playerCamera = Instantiate(playerCameraPrefab); } for (var i = GameAgent.GetEnumerator(); i.MoveNext();) { if (i.Current) { i.Current.OnBeforeSpawnPlayer(reset); } } var camera = spawnPoint.camera ? spawnPoint.camera : defaultCamera; var cameraTransform = camera.transform; cameraTransform.parent = playerCamera.eyeTransform ? playerCamera.eyeTransform : playerCamera.transform; cameraTransform.localPosition = Vector3.zero; cameraTransform.localRotation = Quaternion.identity; cameraTransform.localScale = Vector3.one; playerCamera.camera = camera; playerController.playerCamera = playerCamera; if (audioTransformsUpdater != null) { audioTransformsUpdater(playerController.transform, camera.transform); } spawnPoint.Spawn(playerController, reset); for (var i = GameAgent.GetEnumerator(); i.MoveNext();) { if (i.Current) { i.Current.OnAfterSpawnPlayer(spawnPoint, reset); } } Profiler.EndSample(); }
public virtual void OnSpawn(SpawnPoint spawnPoint, bool reset) { }
public virtual void OnAfterSpawnPlayer(SpawnPoint point, bool reset) { }