Shooting Animations Added
This commit is contained in:
@@ -20,6 +20,8 @@ namespace AI
|
||||
protected Transform target = null;
|
||||
protected bool isShooting = false;
|
||||
protected IMovement movement = null;
|
||||
protected Animator animator = null;
|
||||
protected int layerMask = ~(1 << 9);
|
||||
|
||||
protected bool canShoot => target != null && (target.transform.position - transform.position).sqrMagnitude < attackRangeSquared;
|
||||
|
||||
@@ -41,6 +43,7 @@ namespace AI
|
||||
protected virtual void Start()
|
||||
{
|
||||
movement = transform.GetComponentInParent<IMovement>();
|
||||
animator = transform.GetComponentInParent<Animator>();
|
||||
UpdateTarget(FindObjectOfType<Player.PlayerController>()?.transform);
|
||||
}
|
||||
|
||||
@@ -57,8 +60,11 @@ namespace AI
|
||||
isShooting = true;
|
||||
float movementBaseSpeed = movement.BaseSpeed;
|
||||
movement.BaseSpeed = 0f;
|
||||
animator.SetBool("isAttacking", true);
|
||||
|
||||
animator.speed = 0f;
|
||||
yield return new WaitForSeconds(focusingTime);
|
||||
animator.speed = 1f;
|
||||
|
||||
while (canShoot)
|
||||
{
|
||||
@@ -67,6 +73,7 @@ namespace AI
|
||||
yield return null;
|
||||
}
|
||||
movement.BaseSpeed = movementBaseSpeed;
|
||||
animator.SetBool("isAttacking", false);
|
||||
isShooting = false;
|
||||
}
|
||||
|
||||
@@ -77,7 +84,7 @@ namespace AI
|
||||
|
||||
Vector3 velocity = GetVelocityForProjectile(timeForProjectileToHit);
|
||||
|
||||
RaycastHit2D raycastHit2D = Physics2D.Raycast(transform.position, target.position - transform.position, attackRange);
|
||||
RaycastHit2D raycastHit2D = Physics2D.Raycast(transform.position, target.position - transform.position, attackRange, layerMask);
|
||||
if (raycastHit2D.transform != target)
|
||||
velocity = GetVelocityForProjectile(timeForProjectileToHit * 2);
|
||||
|
||||
|
Reference in New Issue
Block a user