void Attack()
    {
        timer = 0f;

        if (playerHealth.currentHealth > 0)
        {
            playerHealth.TakeDamage(attackDamage);
        }
    }
Exemplo n.º 2
0
    void Shoot()
    {
        timer = 0f;

        ShootRay.origin    = transform.position;
        ShootRay.direction = transform.forward;

        if (Physics.Raycast(ShootRay, out shootHit, Range, ShootableMask))
        {
            SoldierHealth soldierHealth = shootHit.collider.GetComponent <SoldierHealth>();
            if (soldierHealth != null)
            {
                soldierHealth.TakeDamage(damagePerShot, shootHit.point);
            }
            gunLine.SetPosition(1, shootHit.point);
        }
        else
        {
            gunLine.SetPosition(1, ShootRay.origin + ShootRay.direction * Range);
        }
    }