예제 #1
0
    private void UpdatePlaceholderArrow()
    {
        if (primaryTriggerValue <= 0)
        {
            arrowHeld = false;
        }

        arrowPlaceholder.enabled = pullDistance <= 0;
        arrowPlaceholder.gameObject.SetActive(arrowHeld);

        if (arrowHeld)
        {
            if (bow.AtArrowPosition(arrowPlaceholder.transform.position))
            {
                arrowInPlace = true;
            }
            Vector3 alignedPosition = Vector3.zero;
            pullDistance = 0;
            if (arrowInPlace)
            {
                pullDistance = bow.PullAmount(rightHandControllerPosition);
                if (pullDistance > 0)
                {
                    alignedPosition = bow.arrowPlacement.position - bow.arrowPlacement.forward * pullDistance;
                    arrowPlaceholder.transform.position = alignedPosition;
                    arrowPlaceholder.transform.forward  = bow.transform.forward;
                }
            }

            if (pullDistance <= 0)
            {
                arrowInPlace = false;
            }
        }
        else
        {
            arrowInPlace = false;
            pullDistance = 0;

            arrowHeld = primaryTriggerValue > 0 && quiverBounds.GetTotalBounds(true).Contains(rightHandControllerPosition);
        }

        bow.SetPullPercent(pullDistance / bow.maxPullDistance);
    }
예제 #2
0
    private void UpdatePlaceholderArrow()
    {
        if ((arrowHand == Hand.left && !leftTrigger) || (arrowHand == Hand.right && !rightTrigger))
        {
            arrowHeld = false;
            arrowHand = Hand.none;
        }

        arrowTransform.gameObject.SetActive(arrowHeld && canShoot);

        if (arrowHand == Hand.left)
        {
            arrowHandPosition = leftHandPosition;
            arrowHandRotation = leftHandRotation;
        }
        else if (arrowHand == Hand.right)
        {
            arrowHandPosition = rightHandPosition;
            arrowHandRotation = rightHandRotation;
        }

        if (arrowHeld)
        {
            if (bow.AtArrowPosition(arrowHandPosition))
            {
                arrowInPlace = true;
            }
            Vector3 alignedPosition = Vector3.zero;
            pullDistance = 0;
            if (arrowInPlace)
            {
                pullDistance = bow.PullAmount(arrowHandPosition);
                if (pullDistance > 0)
                {
                    alignedPosition         = bow.arrowPlacement.position - bow.arrowPlacement.forward * pullDistance;
                    arrowTransform.position = alignedPosition;
                    arrowTransform.rotation = bow.arrowPlacement.rotation;
                }
            }
            else
            {
                arrowTransform.position = arrowHandPosition;
                arrowTransform.rotation = arrowHandRotation;
            }

            if (pullDistance <= 0)
            {
                arrowInPlace = false;
            }

            quiverBoundsRenderer.material.color = Color.white;
        }
        else if (canShoot)
        {
            arrowInPlace = false;
            pullDistance = 0;

            if (leftTrigger && leftHandInQuiver)
            {
                arrowHeld = true;
                arrowHand = Hand.left;
                PlayArrowTakeAudio(leftHandPosition);
            }
            else if (rightTrigger && rightHandInQuiver)
            {
                arrowHeld = true;
                arrowHand = Hand.right;
                PlayArrowTakeAudio(rightHandPosition);
            }
        }

        bow.SetPullPercent(pullDistance / bow.maxPullDistance);
    }