protected override void Attack() { if (bowAngel != 0) { Vector3 characterPos = character.position; Vector3 arrowPos = arrow.position; Vector3 direction = FlipX ? arrow.right : -arrow.right; // ВЫСЧИТЫВАЕМ V(СИЛУ) float x = characterPos.x - arrowPos.x; if (x < 0) { x = x * -1; bowAngel = 180 - bowAngel; } float y = 0; float h = arrowPos.y - characterPos.y; // ВОЗМОЖНО БАГ float alpha = Methods.GradToRad(bowAngel); // ВОЗМОЖНО БАГ float velocity = Mathf.Sqrt(-Physics2D.gravity.magnitude * Mathf.Pow(x, 2) / ((y - Mathf.Tan(alpha) * x - h) * 2 * Mathf.Pow(Mathf.Cos(alpha), 2))); velocity = Mathf.Clamp(velocity, 0, maxVelocity); direction *= velocity; BulletFactory.CreateArrow(arrow, damage, direction, tag); } }
private void Shoot(float charge, int damage) { Vector3 force = CharacterController.Get_FlipX() ? -transform.right : transform.right; force *= charge; if (Managers.Player.HasLigth) { BulletFactory.CreateArrowWithLight(transform, damage, force, tag); } else { BulletFactory.CreateArrow(transform, damage, force, tag); } }