Esempio n. 1
0
 public void ShootProjectile()
 {
     foreach (GameObject target in currentTargets)
     {
         var pb = Instantiate(currentAttack.projectilePrefab, firePoint);
         pb.transform.parent = null;
         ProjectileBehaviour p = pb.GetComponent <ProjectileBehaviour>();
         p.damage            = (currentAttack.baseDamage * _entityDamage);
         p.AllowedTargetTags = _attackTargeting.AllowedTargetTags;
         var targetDirection = transform.forward;
         if (target != null)
         {
             targetDirection = -(transform.position - target.transform.position).normalized;
         }
         targetDirection.y = 0;
         try
         {
             p.GetComponent <Rigidbody>().AddForce(targetDirection * currentAttack.shootForce);
         }
         catch {}
     }
     ClearTargets();
 }