void WingSnap() { animCancel = true; transform.parent = null; //gameObject.AddComponent<Rigidbody2D>(); GetComponentInChildren <PolygonCollider2D>().isTrigger = false; GetComponent <Rigidbody2D>().constraints = RigidbodyConstraints2D.None; GetComponent <Rigidbody2D>().AddForce(Random.Range(200f, 500f) * Random.insideUnitCircle); parentBatBehaviour.WingSnapped(); Destroy(this); }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.tag == "Enemy") { BatBehaviour tempBat = collision.collider.GetComponentInParent <BatBehaviour>(); if (tempBat != null) { Debug.Log("A bat killed a part of Frank"); DestroyBodyPart(); tempBat.WingSnapped(); } } }