IEnumerator dashTransition(Vector2 direction) { float currentTime = 0.0f; canDash = false; charAnimator.SetBool("IsDash", true); dashParticles.Play(); dashParticles.transform.localScale = transform.localScale; Vector2 oldPosition = transform.position; while (currentTime < 0.2f) { ownCollider.enabled = false; bigCollider.enabled = false; RaycastHit2D[] hits = new RaycastHit2D[100]; ContactFilter2D filter = new ContactFilter2D(); filter.useTriggers = false; int count = Physics2D.CircleCast(transform.position + (Vector3)hitOffset, hitRadius, direction, filter, hits, hitRadius + dashPower * Time.deltaTime); float distanceDashed = Vector2.Distance(oldPosition, transform.position); ownCollider.enabled = true; bigCollider.enabled = true; Debug.Log("hit something!"); //Debug.Log(distanceDashed); if (count > 0) { for (int i = 0; i < 100; i++) { heroScript other = hits[0].collider.transform.parent.GetComponentInParent <heroScript>(); if (other != null) { other.StartCoroutine(other.wasBumped(stunDuration, direction * distanceDashed)); } } StartCoroutine(DashCooldown()); yield break; //returns } rb.AddForce(direction * dashPower, ForceMode2D.Impulse); currentTime += Time.deltaTime; yield return(new WaitForEndOfFrame()); } StartCoroutine(DashCooldown()); }