예제 #1
0
    public void Fire()
    {
        if (shootCount >= magazineSize)
        {
            return;
        }


        // Raycast
        Ray ray = new Ray(FirePoint.position, FirePoint.forward);

        Debug.DrawRay(ray.origin, ray.direction * 1000f, Color.red, 3f);

        Physics.Raycast(ray, out RaycastHit hit, float.MaxValue, targetLayerMask);


        if (hit.collider)
        {
            Debug.Log(hit.transform.name);
            hit.transform.GetComponent <ShootingTarget>().TargetHit();
        }


        shootCount++;

        OnGunFire.Invoke(magazineSize - shootCount);
    }
예제 #2
0
    public void Reload()
    {
        shootCount = 0;

        OnGunFire.Invoke(magazineSize - shootCount);
    }