public void UseAbility() { if (cooldowntimer <= 0) { cooldowntimer = cooldown; Vector2 newPos; if (playerController.GetMousePositionFromPlayer().magnitude > 24) { newPos = playerController.GetMousePositionFromPlayer().normalized; newPos.x = Mathf.Sqrt(newPos.x * newPos.x * 576) * Mathf.Sign(newPos.x) + playerController.transform.position.x; newPos.y = Mathf.Sqrt(newPos.y * newPos.y * 576) * Mathf.Sign(newPos.y) + playerController.transform.position.y; } else { newPos = playerController.GetMousePosition(); } GameObject newArea = Instantiate(area, newPos, Quaternion.identity); newArea.GetComponent <scr_SkillAbility1Area>().OnCreate(15, playerController.GetCritChance()); } }
public void UseAbility() { if (cooldownTimer <= 0) { cooldownTimer = cooldown / playerController.GetAttackSpeed(); mousePos = playerController.GetMousePositionFromPlayer(); GameObject newProjectile = Instantiate(projectile, new Vector2( playerController.transform.position.x + mousePos.normalized.x * 0.5f, playerController.transform.position.y + mousePos.normalized.y * 0.5f), Quaternion.identity); newProjectile.GetComponent <scr_AttackAbility1Projectile>().OnCreate(mousePos.normalized, 10, playerController.GetCritChance()); newProjectile.GetComponent <Transform>().Rotate(0, 0, Mathf.Atan2(mousePos.y, mousePos.x) * Mathf.Rad2Deg - SPRITE_ROTATION, Space.Self); } }