// Update is called once per frame void Update() { if (air > 0) { air -= Time.deltaTime * airBurnRate; } else { Destroy(gameObject); var percent = 0; var t = transform; for (int i = 0; i < totalBubbles; i++) { t.TransformPoint(0, -100, 0); FadeOverTime clone = Instantiate(bubbles, t.position, Quaternion.identity) as FadeOverTime; //generate if go left or right clone.GetComponent <Rigidbody2D> ().AddForce(Vector3.right * Random.Range(-50, 50)); //how high it goes clone.GetComponent <Rigidbody2D> ().AddForce(Vector3.up * Random.Range(100, 400)); } } }
/// <summary> /// need to transition to hurt animation /// Wont reset? /// </summary> void OnHurt() { var t = transform; for (int i = 0; i < totalBubbles; i++) { t.TransformPoint(0, -100, 0); FadeOverTime clone = Instantiate(bubbles, t.position, Quaternion.identity) as FadeOverTime; //generate if go left or right clone.GetComponent <Rigidbody2D> ().AddForce(Vector3.right * Random.Range(-50, 50)); //how high it goes clone.GetComponent <Rigidbody2D> ().AddForce(Vector3.up * Random.Range(100, 400)); } }