private void OnTriggerEnter(Collider other) { //If the player enters, we set the new checkpoint if (other.tag == "Player") { RespawnController charaRespawn = other.GetComponent <RespawnController>(); charaRespawn.SetNewSpawn(other.transform.position, other.transform.rotation); checkpointController.NewCheckpoint(numCheckpoint, activeCamera); } }
/// <summary> /// When the input for the checkpoint is triggered, we call the "death" function, and set the camera. /// </summary> /// <param name="numcp"></param> void GoToCheckpoint(int numcp = -1) { if (numcp != -1) { numCheckpoint = numcp; } Checkpoint checkpointScript = null; foreach (GameObject obj in GameObject.FindGameObjectsWithTag("Checkpoint")) { if (obj.GetComponent <Checkpoint>().numCheckpoint == numCheckpoint) { checkpointScript = obj.GetComponent <Checkpoint>(); } } if (checkpointScript != null) { currentCam = checkpointScript.activeCamera; charaRespawnController.SetNewSpawn(checkpointScript.spawnPos.position); characterControllerScript.Death(); } }