Пример #1
0
    void Attack()
    {
        audio.PlayOneShot(attackSoundClip);

        lastAttackTime = Time.time;

        playerStats.ammoCount--;

        if (hasFired != null)
        {
            hasFired();
        }


        RaycastHit hit;
        var        camera = Camera.main;


        var direction = camera.transform.TransformDirection(Vector3.forward);

        if (Physics.Raycast(camera.transform.position, direction, out hit, attackDistance, hitMask) == false)
        {
            return;
        }

        ActivateHitables.HitAll(hit.collider.gameObject);
    }
Пример #2
0
    public LayerMask hitMask; //the reason is if we might want to ignore more than player object



    void Attack()
    {
        //this crates a sphere cast at a point we determine and checks if it has intersected with any game objects
        var hits = Physics.OverlapSphere(AttackPoint.position, 0.5f, hitMask);

        foreach (var hit in hits)
        {
            ActivateHitables.HitAll(hit.gameObject);
        }
    }
Пример #3
0
    private void Attack()
    {
        if (!IsInAttackRange && enemyKill.IsDead)
        {
            return;
        }

        ActivateHitables.HitAll(player.gameObject);

        animation.CrossFade(attackAnimation.name);

        audio.PlayOneShot(attackAudio);

        isCharging = false;
    }