Exemplo n.º 1
0
        /// <summary>
        /// Try to grab items
        /// </summary>
        private void UpdateGrabObjects()
        {
            //Debug.Log(HandData.GetCloseValue(DeviceType));
            if (_grabbedItem != null || HandData.GetCloseValue(DeviceType) == CloseValue.Fist)
            {
                return;
            }
            // Always try to grab a item when the user is making a fist
            if (HandData.FirstJointAverage(DeviceType) > 0.32f && _physicsHand.AmountOfCollidingObjects() > 0)
            {
                foreach (var rb in TriggerBinder.CollidingInteractables)
                {
                    GrabItem(rb);
                }
            }


            if (_physicsHand.IsThumbColliding && _physicsHand.AmountOfCollidingObjects() > 1 && HandData.FirstJointAverage(DeviceType) > 0.07f)
            {
                foreach (var rb in TriggerBinder.CollidingInteractables)
                {
                    GrabItem(rb);
                }
            }
        }
Exemplo n.º 2
0
        public override void RotateWrist(Quaternion rotation)
        {
            if (PhysicsWristSettings == null)
            {
                return;
            }

            if (_isFrozen && _selfRigidbody != null && Hand.HandData.HasReceivedData(DeviceType == device_type_t.GLOVE_LEFT
                    ? GloveLaterality.GLOVE_LEFT
                    : GloveLaterality.GLOVE_RIGHT))
            {
                _isFrozen = false;
                _selfRigidbody.constraints = RigidbodyConstraints.None;
            }


            if (_targetRigidbody != null)
            {
                var maxRotationDelta = _physicsHand.AmountOfCollidingObjects() > 0 ? PhysicsWristSettings.MaxRotDeltaCollding : PhysicsWristSettings.MaxRotDeltaNotColliding;
                _targetRigidbody.MoveRotation(Quaternion.RotateTowards(Rigidbody.rotation, rotation, maxRotationDelta));
            }

            if (_wristJoint != null || _physicsHand == null)
            {
                return;
            }

            var maxAngularVelocity = _physicsHand.AmountOfCollidingObjects() > 0 ? PhysicsWristSettings.MaxAngularVelocityColliding : PhysicsWristSettings.MaxAngularVelocityNotColliding;

            RotateBody(rotation, Rigidbody, 100, maxAngularVelocity, 1);
        }
Exemplo n.º 3
0
        public override void RotateWrist()
        {
            if (PhysicsWristSettings == null)
            {
                return;
            }

            if (_targetRigidbody != null)
            {
                var maxRotationDelta = _physicsHand.AmountOfCollidingObjects() > 0 ? PhysicsWristSettings.MaxRotDeltaCollding : PhysicsWristSettings.MaxRotDeltaNotColliding;
                _targetRigidbody.MoveRotation(Quaternion.RotateTowards(Rigidbody.rotation, WristRotation(), maxRotationDelta));
            }

            if (_wristJoint != null)
            {
                return;
            }
            var maxAngularVelocity = _physicsHand.AmountOfCollidingObjects() > 0 ? PhysicsWristSettings.MaxAngularVelocityColliding : PhysicsWristSettings.MaxAngularVelocityNotColliding;

            RotateBody(WristRotation(), Rigidbody, 100, maxAngularVelocity, 1);
        }