Пример #1
0
    private void Update()
    {
        Ray        ray = FPSCamera.ScreenPointToRay(new Vector2(Screen.width / 2, Screen.height / 2));
        RaycastHit hitInfo;

        if (Input.GetKeyDown(KeyCode.Mouse0))                   // Shoot at target when we mouse click
        {
            if (Physics.Raycast(ray, out hitInfo, weaponRange)) // Checks for collision of the ray
            {
                if (hitInfo.collider.tag == "Zombie")
                {
                    zombieAI = hitInfo.collider.GetComponent <AdvancedZombieAI>();
                    zombieAI.TakeDamage(Damage());
                }
            }
        }
    }
Пример #2
0
    private void AttackEnemy()
    {
        int damage = Random.Range(minDamage, maxDamage);

        zombieAI.TakeDamage(damage);
    }