public void SwitchForm(GameObject form) { if (form.name.Equals(currentPlayerForm.name)) { return; } Vector3 pos = currentPlayerForm.transform.position; currentPlayerForm.FreezePosition(true); currentPlayerForm.gameObject.SetActive(false); foreach (Transform pf in playerForms) { if (form.name.Equals(pf.name)) { currentPlayerForm = pf.GetComponent <PlayerForm>(); } } currentPlayerForm.gameObject.SetActive(true); currentPlayerForm.TeleportToPosition(pos); currentPlayerForm.FreezePosition(false); Camera.main.GetComponent <MyCamera>().target = currentPlayerForm.transform; // TODO: merge SwichForm functions into one }
public void SwitchFormNext() { Vector3 pos = currentPlayerForm.transform.position; currentPlayerForm.FreezePosition(true); currentPlayerForm.gameObject.SetActive(false); int currentPlayerFormIndex = playerForms.IndexOf(currentPlayerForm.transform); int nextPlayerFormIndex = currentPlayerFormIndex + 1; if (nextPlayerFormIndex >= playerForms.Count) { nextPlayerFormIndex = 0; } currentPlayerForm = playerForms[nextPlayerFormIndex].GetComponent <PlayerForm>(); currentPlayerForm.gameObject.SetActive(true); currentPlayerForm.TeleportToPosition(pos); currentPlayerForm.FreezePosition(false); Camera.main.GetComponent <MyCamera>().target = currentPlayerForm.transform; // TODO: merge SwichForm functions into one }