private void Update() { //if inside of trigger if (gameController.getInteraction() && Input.GetKeyDown(KeyCode.E)) { //set visible square text and interaction with element is true squareText.SetActive(true); //only enter one time per checkpoint if (!checkPoint) { //save position gameController.setcheckPoint(new Vector3(transform.position.x, transform.position.y, -10)); //only one checkpoint gameController.setcheckPointController(true); checkPoint = true; print("solo una vez"); print(gameController.getcheckPoint()); } gameController.setInteraction(false); } //interaction is false else if (!gameController.getInteraction() && Input.GetKeyDown(KeyCode.E)) { //set visible square text and finish of interaction squareText.SetActive(false); gameController.setInteraction(true); } }
IEnumerator RespawnCheckPoint() { //reset life gameController.setLife(-100); //Stop fps Time.timeScale = 0; //Fade ON fade = true; yield return(new WaitForSecondsRealtime(timeToFade)); //new position of player and camera is the gameobject checkpoint position player.transform.position = new Vector3(gameController.getcheckPoint().x, gameController.getcheckPoint().y, 0); Camera.main.transform.position = new Vector3(gameController.getcheckPoint().x, gameController.getcheckPoint().y + correctionCameraHeight, -10); //Return fps Time.timeScale = 1; //Fade OFF fade = false; //Don't repeat checkpoint tranform position gameController.setcheckPointController(false); print("enter checkpoint condition"); }