Exemplo n.º 1
0
 protected void UpdateBowHandCollision(HVRHandGrabber hand, HVRGrabbable arrow, bool enable)
 {
     if (hand && arrow)
     {
         hand.UpdateCollision(arrow, enable);
     }
 }
Exemplo n.º 2
0
        protected override void Start()
        {
            base.Start();

            if (GrabStyle == HVRForceGrabMode.ForcePull)
            {
                RequiresFlick = false;
            }

            if (!HandGrabber)
            {
                HandGrabber = GetComponentInChildren <HVRHandGrabber>();
            }

            if (!HandGrabber)
            {
                Debug.LogWarning("Cannot find HandGrabber. Make sure to assign or have it on this level or below.");
            }

            CheckForceAnchor();

            if (!ForcePullSettings)
            {
                ForcePullSettings = ScriptableObject.CreateInstance <HVRForcePullSettings>();
            }
        }
Exemplo n.º 3
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();
        }
Exemplo n.º 4
0
 private void OnDialReleased(HVRHandGrabber arg0, HVRGrabbable arg1)
 {
     Joint.SetAngularXDrive(Spring, Damper, 10000f);
     if (StopOnRelease)
     {
         Rigidbody.angularVelocity = Vector3.zero;
     }
 }
Exemplo n.º 5
0
 protected virtual void OnHandReleased(HVRHandGrabber arg0, HVRGrabbable arg1)
 {
     if (Arrow)
     {
         StartCoroutine(EnableBowHandCollisionRoutine(arg0, Arrow.Grabbable));
     }
     BowHand = null;
 }
Exemplo n.º 6
0
 private void OnStringGrabbed(HVRHandGrabber arg0, HVRGrabbable arg1)
 {
     if (!bow.ArrowNocked && ArrowPrefab)
     {
         var go    = Instantiate(ArrowPrefab);
         var arrow = go.GetComponent <HVRArrow>();
         bow.NockArrow(arrow);
     }
 }
Exemplo n.º 7
0
        protected override void OnStringGrabbed(HVRHandGrabber hand, HVRGrabbable nock)
        {
            if (Arrow)
            {
                hand.DisableHandCollision(Arrow.Grabbable);
            }

            _stringJoint.SetXDrive(StringHeldSpring, 0, StringHeldSpring);
        }
Exemplo n.º 8
0
        private void OnReleased(HVRGrabberBase grabber, HVRGrabbable arg1)
        {
            if (!grabber.IsHandGrabber)
            {
                return;
            }

            _handGrabber = null;
            if (ResetOnRelease)
            {
                Close();
            }
        }
Exemplo n.º 9
0
        private void OnGrabbed(HVRGrabberBase grabber, HVRGrabbable arg1)
        {
            if (!grabber.IsHandGrabber)
            {
                return;
            }

            _handGrabber = grabber as HVRHandGrabber;
            //HandCheckAnchor.transform.localPosition = PumpGrabbable.transform.InverseTransformPoint(_handGrabber.GrabPoint.position);
            HandCheckAnchor.transform.position = _handGrabber.GrabPoint.position;
            _previousHandPosition = _handGrabber.TrackedController.position;
            _previousVelocity     = Vector3.zero;
        }
Exemplo n.º 10
0
        protected IEnumerator EnableBowHandCollisionRoutine(HVRHandGrabber hand, HVRGrabbable arrow)
        {
            if (!hand || !arrow)
            {
                yield break;
            }
            yield return(new WaitForSeconds(.25f));

            if (BowHand && BowHand == hand || !arrow)
            {
                yield break;
            }
            UpdateBowHandCollision(hand, arrow, true);
        }
Exemplo n.º 11
0
        protected virtual void OnArrowSocketed(HVRGrabberBase arg0, HVRGrabbable grabbable)
        {
            var arrow = grabbable.transform.GetComponent <HVRArrow>();

            if (!arrow)
            {
                NockHand = null;
                Debug.LogWarning($"{grabbable.name} missing HVRArrow component.");
                return;
            }


            OnArrowNocked(arrow);
        }
Exemplo n.º 12
0
        protected void OnReleased(HVRGrabberBase grabber, HVRGrabbable hvrGrabbable)
        {
            PrimaryGrabber = null;

            if (DiscardAngle)
            {
                if (_rigidBody)
                {
                    _rigidBody.MoveRotation(RotationTarget.rotation);
                }
                else
                {
                    transform.localRotation = RotationTarget.localRotation;
                }
            }
        }
Exemplo n.º 13
0
        private IEnumerator RenablePhysics(HVRGrabbable grabbable, HVRHandGrabber hand)
        {
            yield return(new WaitForSeconds(2.50f));

            foreach (var ourCollider in Grabbable.Colliders)
            {
                foreach (var ammoCollider in grabbable.Colliders)
                {
                    Physics.IgnoreCollision(ourCollider, ammoCollider, false);
                }
            }

            if (hand)
            {
                hand.HandPhysics.IgnoreCollision(grabbable.Colliders, false);
            }
        }
Exemplo n.º 14
0
        protected virtual void OnHandGrabbed(HVRHandGrabber hand, HVRGrabbable bow)
        {
            BowHand = hand;

            if (Arrow)
            {
                UpdateBowHandCollision(hand, Arrow.Grabbable, false);
            }

            if (hand.HandSide == HVRHandSide.Left && !ReverseArrowsRests)
            {
                Rest = LeftRest;
            }
            else
            {
                Rest = RightRest;
            }
        }
Exemplo n.º 15
0
 public HandHelper(HVRPlayerController hvrPlayerController)
 {
     this.hvrPlayerController = hvrPlayerController;
     leftHand  = hvrPlayerController.LeftHand;
     rightHand = hvrPlayerController.RightHand;
 }
Exemplo n.º 16
0
 private void OnDialGrabbed(HVRHandGrabber arg0, HVRGrabbable arg1)
 {
     Joint.SetAngularXDrive(0f, GrabbedDamper, 10000f);
 }
Exemplo n.º 17
0
 private void BeforeNockHovered(HVRGrabberBase grabber, HVRGrabbable grabbable)
 {
     NockHand = grabbable.PrimaryGrabber as HVRHandGrabber;
 }
Exemplo n.º 18
0
 protected override void OnStringReleased(HVRHandGrabber arg0, HVRGrabbable arg1)
 {
     _stringJoint.SetXDrive(StringSpring, 0f, StringSpring);
 }
Exemplo n.º 19
0
 protected virtual void OnStringGrabbed(HVRHandGrabber hand, HVRGrabbable nock)
 {
 }
Exemplo n.º 20
0
 protected virtual void OnStringReleased(HVRHandGrabber arg0, HVRGrabbable arg1)
 {
 }