예제 #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);
    }