//Por defecto, los enemigos comenzarán a moverse hacia la derecha del eje x void Start() { sum = gameObject.GetComponent <Summoner>(); detectionArea = gameObject.GetComponentInChildren <PlayerNexusDetection>(); sprite = gameObject.GetComponentInChildren <Animator>(); Rotation(dir); }
//Método para cambiar la rotación del area de ataque fisico y la orientación de los sprites de los enemigos public void Rotation(Vector2 newdir) { //Melees invocados por el distancia (¿Pierden la referencia?) if (detectionArea == null) { detectionArea = this.gameObject.GetComponentInChildren <PlayerNexusDetection>(); } if (sprite == null) { sprite = this.gameObject.GetComponentInChildren <Animator>(); } //Mismo eje, sentido contrario if (dir == -1 * newdir) { detectionArea.ChangeRotation(180); sprite.transform.Rotate(0, 0, 180); } //Mismo eje misma direccion else if (dir == newdir) { detectionArea.ChangeRotation(0); } //Cambio de eje, pasamos de movernos en y a movernos en x else if (dir.x == 0) { if (newdir.x == dir.y) { detectionArea.ChangeRotation(-90); sprite.transform.Rotate(0, 0, -90); } else { detectionArea.ChangeRotation(90); sprite.transform.Rotate(0, 0, 90); } } //Cambio de eje, pasamos de movernos en x a movernos en y else { if (newdir.y == dir.x) { detectionArea.ChangeRotation(90); sprite.transform.Rotate(0, 0, 90); } else { detectionArea.ChangeRotation(-90); sprite.transform.Rotate(0, 0, -90); } } }