void OnCollisionEnter2D(Collision2D other) { if (other.collider.tag == "LeftBound") { ContactPoint2D contact = other.contacts[0]; LeftPoint.x = contact.point.x; LeftPoint.y = contact.point.y; Collis = Instantiate(LeftCollision) as GameObject; Collis.transform.position = new Vector3(LeftPoint.x, LeftPoint.y, 5f); sound.playCollisionSound(); StartCoroutine("PlayLeftCollision"); } if (other.collider.tag == "RightBound") { ContactPoint2D contact = other.contacts[0]; LeftPoint.x = contact.point.x; LeftPoint.y = contact.point.y; Collis = Instantiate(RightCollision) as GameObject; Collis.transform.position = new Vector3(LeftPoint.x, LeftPoint.y, 5f); sound.playCollisionSound(); StartCoroutine("PlayRightCollision"); } if (other.collider.tag == "LimitlessPlatforms") { this.transform.SetParent(other.transform); sound.playCollisionSound(); } }
void OnCollisionEnter2D(Collision2D other) { sound.playCollisionSound(); if (other.collider.tag == "OtherWall") { transform.SetParent(null); } }