IEnumerator Transition(Vector3 offset, bool enter) { player_control.Disable(); if (enter == false) { dialogue.GetComponent <Dialogue>().ClearText(); block.transform.position = new Vector3(block.transform.position.x - 1, block.transform.position.y, block.transform.position.z); block.GetComponent <Movable>().is_moved = false; } Vector3 initial_position = rm.transform.position; Vector3 final_position = initial_position + offset; float initial_time = Time.time; float progress = (Time.time - initial_time) / duration; while (progress < 1.0f) { progress = (Time.time - initial_time) / duration; Vector3 new_position = Vector3.Lerp(initial_position, final_position, progress); rm.transform.position = new_position; yield return(null); } rm.transform.position = final_position; if (offset.x > 0) { offset = new Vector3(2.5f, 0, 0); } if (offset.x < 0) { offset = new Vector3(-1.5f, 0, 0); } player.GetComponent <Rigidbody>().MovePosition(transform.position); player.GetComponent <Rigidbody>().MovePosition(transform.position + offset); if (enter) { StartCoroutine(dialogue.GetComponent <Dialogue>().Display(dialogue.GetComponent <Dialogue>().dialogue_text[0])); } else { block.GetComponent <UnlockSpecialDoor>().target.GetComponent <SpriteRenderer>().sprite = block.GetComponent <UnlockSpecialDoor>().locked; block.GetComponent <UnlockSpecialDoor>().target.layer = 0; player_control.Enable(); } }
IEnumerator Transition(Vector3 offset) { player_control.Disable(); Vector3 initial_position = rm.transform.position; Vector3 final_position = initial_position + offset; float initial_time = Time.time; float progress = (Time.time - initial_time) / duration; while (progress < 1.0f) { progress = (Time.time - initial_time) / duration; Vector3 new_position = Vector3.Lerp(initial_position, final_position, progress); rm.transform.position = new_position; yield return(null); } rm.transform.position = final_position; if (offset.x > 0) { offset = new Vector3(1.5f, 0, 0); } if (offset.x < 0) { offset = new Vector3(-1.5f, 0, 0); } if (offset.y > 0) { offset = new Vector3(0, 1.5f, 0); } if (offset.y < 0) { offset = new Vector3(0, -1.5f, 0); } player.GetComponent <Rigidbody>().MovePosition(transform.position); player.GetComponent <Rigidbody>().MovePosition(transform.position + offset); player_control.Enable(); }
IEnumerator Transition(Vector3 offset) { player_control.Disable(); Vector3 initial_position = rm.transform.position; Vector3 final_position = initial_position + offset; float initial_time = Time.time; float progress = (Time.time - initial_time) / duration; while (progress < 1.0f) { progress = (Time.time - initial_time) / duration; Vector3 new_position = Vector3.Lerp(initial_position, final_position, progress); rm.transform.position = new_position; yield return(null); } rm.transform.position = final_position; player_control.Enable(); }
IEnumerator Transition(Vector3 offset) { player_control.Disable(); Vector3 initial_position = rm.transform.position; Vector3 final_position = initial_position + offset; // for (int i = 0; i < 10; i++) // { // yield return null; // } rm.transform.position = final_position; if (offset.y > 0) { player.GetComponent <Rigidbody>().MovePosition(new Vector3(19, 76, 0)); player.GetComponent <Rigidbody>().MovePosition(new Vector3(19, 75, 0)); // animator.SetFloat("horizontal_input", 0); // animator.SetFloat("vertical_input", -1f); // for (int i = 0; i < 10; i++) // { // yield return null; // } } else { player.GetComponent <Rigidbody>().MovePosition(new Vector3(22, 59, 0)); } for (int i = 0; i < 10; i++) { yield return(null); } player_control.Enable(); }