Projectile Shooting Audio Added

This commit is contained in:
2022-02-26 17:57:04 +03:00
parent e80158e77f
commit 3ccc7a24b8
10 changed files with 164 additions and 0 deletions

View File

@@ -21,6 +21,7 @@ namespace AI
protected bool isShooting = false;
protected IMovement movement = null;
protected Animator animator = null;
protected AudioSource audioSource = null;
protected int layerMask = ~(1 << 9);
protected bool canShoot => target != null && (target.transform.position - transform.position).sqrMagnitude < attackRangeSquared;
@@ -44,6 +45,7 @@ namespace AI
{
movement = transform.GetComponentInParent<IMovement>();
animator = transform.GetComponentInParent<Animator>();
audioSource = transform.GetComponentInParent<AudioSource>();
UpdateTarget(FindObjectOfType<Player.PlayerController>()?.transform);
}
@@ -90,6 +92,7 @@ namespace AI
projectile.SetVelocity(velocity);
remainingCooldown = cooldownPerShoot;
audioSource.Play();
OnShoot?.Invoke();
}