void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject == player) { if (!EarthDash.earthDashEnded && breakableOnEarthDash && playerstate.element == Elements.elements.earth) { heightDashEnded = player.transform.position.y; DebugHelper.Log("Travelled " + (EarthDash.heightDashedAt - heightDashEnded) + " units with earth dash trying to break a platform"); collisionManager.CheckGroundedObject(); //check we travelled the distance we want and if we did break the platform if (EarthDash.heightDashedAt - heightDashEnded >= dashDistanceRequiredToBreak && CollisionManager.groundedObject == this.gameObject) { EarthDash.earthDashEnded = true; p_collider.enabled = false; DebugHelper.Log(this.gameObject + " had collision disabled because it was broken from earthdash"); broken = true; DebugHelper.Log(this.gameObject + " is being destroyed because it was broken from earthdash"); Destroy(gameObject, timeToDestroyAfterBreak); } } else if (CollisionManager.groundedObject == this.gameObject && (oscillateHorizontally || oscillateVertically)) { player.transform.parent = this.transform; DebugHelper.Log("Player transform is being parented by " + this.gameObject + " because it is oscillating"); } } }