private void Shoot()
        {
            if (muzzleFlashFX)
            {
                muzzleFlashFX.Play();
            }

            RaycastHit hit            = hitInfo.GetHit(range, hitLayer);
            Vector3    shootDirection = hitInfo.Direction;

            if (hit.rigidbody)
            {
                float hitDistance = hit.distance;
                //float hitDistance = Vector3.Distance(transform.position, hit.point);
                float acceleration = hitDistance * distanceToAccelerationMult;
                hit.rigidbody.velocity += Mathf.Abs(range - hitDistance) * shootDirection;
                hit.rigidbody.velocity  = Vector3.ClampMagnitude(hit.rigidbody.velocity, objectMaxSpeed);
                Health targetHealth = hit.transform.GetComponent <Health>();

                if (targetHealth && damageDealer)
                {
                    DamageDealer.DealDamage(targetHealth, damage);
                }

                //AIMovement aiMovement = hit.transform.GetComponent<AIMovement>();
                //if (aiMovement)
                //{
                //    aiMovement.KnockBack(shootDirection, true);
                //}
            }
        }
Exemple #2
0
        private void Attack(float damage)
        {
            RaycastHit hit = hitInfo.GetHit(attackRange);

            if (hit.rigidbody)
            {
                Health targetHealth = hit.transform.GetComponent <Health>();

                if (targetHealth && damageDealer)
                {
                    DamageDealer.DealDamage(targetHealth, damage);
                    Debug.Log("[" + controller.gameObject.name + "] Dealt [" + damage + "] Damage");
                }
            }
        }
 private bool IsRayHitObject(out RaycastHit hit, float range)
 {
     hit = hitInfo.GetHit(range, objectLayer);
     return(hit.transform != null);
 }
Exemple #4
0
 private bool IsRayHitObject(out RaycastHit hit, float range, LayerMask grappleLayer)
 {
     hit = hitInfo.GetHit(range, grappleLayer);
     return(hit.transform != null);
 }