// Use this for initialization void Awake() { // Temporarly disables movement enabled = false; enemy = this.GetComponent <Rigidbody2D>(); enemy_barrel = this.GetComponentInChildren <E_Shoot>(); point = new Vector3[3]; // Chooses which side to start on int rand = Random.Range(1, 3); if (rand == 1) { point[0] = new Vector3(-18, 7, 0); point[2] = new Vector3(18, 7, 0); } else { point[2] = new Vector3(-18, 7, 0); point[0] = new Vector3(18, 7, 0); } point[1] = point[0] + (point[2] - point[0]) / 2 + Vector3.up * 15.0f; // Play with 10.0 to change the curve StartCoroutine(Pause()); }
// Use this for initialization void Awake() { // Temporarly disables movement enabled = false; enemy = this.GetComponent <Rigidbody2D>(); enemy_barrel = this.GetComponentInChildren <E_Shoot>(); point = new Vector2[7]; // Chooses which side to start on point[0] = new Vector2(-18, 5); point[1] = new Vector2(0, 5); point[3] = new Vector2(0, 15); point[5] = new Vector2(0, 5); point[6] = new Vector2(18, 5); point[2] = point[1] + (point[3] - point[1]) / 2 + Vector2.right * 10.0f; // Play with 10.0 to change the curve point[4] = point[3] + (point[5] - point[3]) / 2 + Vector2.left * 10.0f; // Play with 10.0 to change the curve // Sets initial position int rand = Random.Range(1, 3); if (rand == 1) { currentPoint = 0; forward = true; enemy.transform.position = new Vector3(point[0].x, point[0].y, 0); } else { currentPoint = 6; forward = false; enemy.transform.position = new Vector3(point[6].x, point[6].y, 0); } StartCoroutine(Pause()); }
// Use this for initialization void Awake() { // Temporarly disables movement (Update function) enabled = false; enemy = this.GetComponent <Rigidbody2D>(); enemy_barrel = this.GetComponentInChildren <E_Shoot>(); point = new Vector2[4]; int rand = Random.Range(1, 3); Debug.Log("Rand: " + rand); if (rand == 1) { point[0] = new Vector2(-18, 15); point[1] = new Vector2(10, 15); point[2] = new Vector2(-10, 5); point[3] = new Vector2(18, 5); } else { point[0] = new Vector2(18, 15); point[1] = new Vector2(-10, 15); point[2] = new Vector2(10, 5); point[3] = new Vector2(-18, 5); } Debug.Log("Wait..."); StartCoroutine(Pause()); nextPoint = 1; forward = true; }