Exemple #1
0
    private void Update()
    {
        if (IsBlocked || selectionService == null || cameraRayProvider == null)
        {
            return;
        }

        selectionService.Refresh();
        int id = -1;

        while (selectionService.DetectSelection(out id))
        {
            Ray ray = cameraRayProvider.GetRay(id);

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

            //the ray can hit nothing, a target or the game board surface
            if (hitInfo.transform != null && hitInfo.transform.parent != null)
            {
                WhackTarget target = hitInfo.transform.parent.GetComponent <WhackTarget>();
                if (target != null)
                {
                    target.GetHit();
                }
            }
        }
    }