public void RangedAttack()
{
if (AttackSound.Count > 0)
{
AudioSource.PlayClipAtPoint(AttackSound.Random(), transform.position);
}
var bullet = Instantiate(Bullet);
if (Tip != null)
{
var ray = _viewCamera.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0));
RaycastHit hit;
Vector3 dir;
if (Physics.Raycast(ray, out hit))
{
dir = (hit.point - Tip.transform.position).normalized;
}
else
{
dir = _viewCamera.transform.forward;
}
bullet.transform.position = Tip.transform.position;
bullet.transform.rotation = Quaternion.LookRotation(dir);
}
else
{
bullet.transform.position = transform.position;
bullet.transform.rotation = transform.rotation;
}
bullet.GetComponent<Bullet>().Damage = Random.Range(1, 5);
_lastShot = Time.fixedTime;
_ammo.RemoveAmmo(AmmoType.Solution, 1);
}