public override bool Cast() { bool wasCast = false; effectAlpha = 1f; Vector2 mousePosition = player.GetComponent <ClickHandler>().getMousePosition(); Vector2 playerPosition = player.GetComponent <Rigidbody2D>().position; RaycastHit2D[] hits = Physics2D.LinecastAll(playerPosition, mousePosition); foreach (RaycastHit2D hit in hits) { if (hit != null && hit.collider != null) { if (hit.collider.gameObject.GetComponent <EnemyController>() != null) { // CombatText combatText = hit.collider.gameObject.AddComponent(typeof(CombatText)) as CombatText; // combatText.text= damage.ToString(); CombatText.Create(hit.collider.gameObject.transform.position, 100.ToString(), false); StatusText.Create(hit.collider.gameObject.transform.position, "Stunned", false); hit.collider.gameObject.GetComponent <CombatTextFactory>().addCombatText("Hit Enemy with dash"); Debug.Log("Hit Enemy with dash"); } } } player.GetComponent <Rigidbody2D>().position = mousePosition; DashEffect.Create(playerPosition, mousePosition); wasCast = true; Debug.Log("Cast Dash"); return(wasCast); }