Пример #1
0
        protected virtual void OnArrowNocked(HVRArrow arrow)
        {
            _previousArrowSleep = arrow.Rigidbody.sleepThreshold;

            arrow.transform.rotation = Quaternion.LookRotation(WorldForward, NockSocket.transform.up);
            arrow.transform.position = NockSocket.transform.position;


            var grabbable = arrow.Grabbable;

            grabbable.ForceRelease();
            grabbable.CanBeGrabbed             = false;
            grabbable.Rigidbody.sleepThreshold = 0f;
            grabbable.Grabbed.AddListener(OnNockedArrowGrabbed);

            UpdateBowHandCollision(BowHand, grabbable, false);

            NockSocket.AllowGrabbing = false;
            Arrow = arrow;

            Grabbable.IgnoreCollision(grabbable);

            if (NockHand)
            {
                NockHand.TryGrab(NockGrabbable, true);
                NockHand = null;
            }

            arrow.EnableForwardGrabbable();
        }
Пример #2
0
        protected override void OnArrowNocked(HVRArrow arrow)
        {
            base.OnArrowNocked(arrow);

            SetupNockJoint(arrow);
            SetupRestJoint(arrow);
        }
Пример #3
0
        public void NockArrow(HVRArrow arrow)
        {
            if (Arrow)
            {
                return;
            }

            OnArrowNocked(arrow);
        }
Пример #4
0
        protected virtual void OnArrowRemoved(HVRArrow arrow)
        {
            this.ExecuteAfterSeconds(() => NockSocket.AllowGrabbing = true, .25f);

            StartCoroutine(EnableBowHandCollisionRoutine(BowHand, arrow.Grabbable));

            arrow.Grabbable.Grabbed.RemoveListener(OnNockedArrowGrabbed);

            arrow.DisableForwardGrabbable();
        }
Пример #5
0
        protected override void OnArrowRemoved(HVRArrow arrow)
        {
            base.OnArrowRemoved(arrow);

            if (_nockJoint)
            {
                Destroy(_nockJoint);
            }

            if (_restJoint)
            {
                Destroy(_restJoint);
            }
        }
Пример #6
0
        private void SetupRestJoint(HVRArrow arrow)
        {
            _restJoint = gameObject.AddComponent <ConfigurableJoint>();

            var axis = Forward;

            _restJoint.axis          = axis;
            _restJoint.secondaryAxis = axis.OrthogonalVector();

            _restJoint.LockYMotion();
            _restJoint.LockZMotion();

            _restJoint.anchor = transform.InverseTransformPoint(Rest.transform.position);
            _restJoint.autoConfigureConnectedAnchor = false;
            _restJoint.connectedBody   = arrow.Rigidbody;
            _restJoint.connectedAnchor = arrow.transform.InverseTransformPoint(Rest.transform.position);
        }
Пример #7
0
        private void SetupNockJoint(HVRArrow arrow)
        {
            _nockJoint = NockRigidbody.gameObject.AddComponent <ConfigurableJoint>();

            var axis = Forward;

            _nockJoint.axis          = axis;
            _nockJoint.secondaryAxis = axis.OrthogonalVector();
            _nockJoint.LockYMotion();
            _nockJoint.LockZMotion();
            _nockJoint.LockLinearMotion();
            _nockJoint.LockAllAngularMotion();
            _nockJoint.anchor = Vector3.zero;
            _nockJoint.autoConfigureConnectedAnchor = false;
            _nockJoint.connectedBody   = arrow.Rigidbody;
            _nockJoint.connectedAnchor = arrow.NotchPointLocal;
        }