Example #1
0
        public override void Start()
        {
            base.Start();
            _physicsHand = Hand as PhysicsHand;
            if (_physicsHand == null)
            {
                Debug.LogWarning("PhysicsWrist needs a PhysicsHand");
            }

            _phalange = HandFactory.GetPhalange(gameObject, 0, 0, DeviceType);
        }
Example #2
0
        public override void Start()
        {
            base.Start();
            _selfRigidbody             = GetComponent <Rigidbody>();
            _selfRigidbody.constraints = RigidbodyConstraints.FreezeRotation;
            _physicsHand = Hand as PhysicsHand;
            if (_physicsHand == null)
            {
                Debug.LogWarning("PhysicsWrist needs a PhysicsHand");
            }

            _phalange = HandFactory.GetPhalange(gameObject, 0, 0, DeviceType);
        }
        public override void Start()
        {
            base.Start();
            //_thumbRigidbody = Phalanges[1].GetComponent<Rigidbody>();
            _physicsHand = Hand as PhysicsHand;
            if (_physicsHand == null)
            {
                Debug.LogError("Physics thumb only works with a physics hand");
            }
            // Get the thumb of the target hand
            ConfigureThumb(Phalanges[1]);

            AddHingeJoint(Phalanges[2], -Hand.WristTransform.right, _thumbRigidbody);
            _phalange = HandFactory.GetPhalange(Phalanges[2], Index, 2, DeviceType);
        }
Example #4
0
        public override void Start()
        {
            base.Start();
            _initialThumbQuaternion = PhalangesGameObjects[1].transform.localRotation;
            _physicsHand            = Hand as PhysicsHand;
            if (_physicsHand == null)
            {
                Debug.LogError("PhysicsFinger needs a PhysicsHand");
            }

            for (var i = 1; i <= 2; i++)
            {
                if (Index == FingerIndex.thumb && i == 1)
                {
                    ConstraintThumbPosition(PhalangesGameObjects[i]);
                    ConstraintThumbRotation(PhalangesGameObjects[i]);
                    continue;
                }

                GameObject holder = PhalangesGameObjects[i];

                GameObject copy = new GameObject(PhalangesGameObjects[i].name);
                //copy.transform.parent = PhalangesGameObjects[i].transform.parent;
                copy.transform.parent   = Hand.transform;
                copy.transform.position = PhalangesGameObjects[i].transform.position;
                copy.transform.rotation = PhalangesGameObjects[i].transform.rotation;

                Collider targetCollider = PhalangesGameObjects[i].GetComponent <Collider>();
                Destroy(targetCollider);
                CopyCollider(targetCollider, copy);
                PhalangesGameObjects[i] = copy;

                // Get the rigidbody where it should connect to
                var connectedBody = ConnectedBody(i);

                // Add a hingejoint to the gameobject
                if (Index == FingerIndex.thumb && DeviceType != device_type_t.GLOVE_LEFT)
                {
                    _joints[i] = AddHingeJoint(PhalangesGameObjects[i],
                                               new Vector3(0, 0, 1), connectedBody);
                }
                else if (Index == FingerIndex.thumb)
                {
                    _joints[i] = AddHingeJoint(PhalangesGameObjects[i],
                                               new Vector3(0, 0, 1), connectedBody);
                }
                else
                {
                    _joints[i] = AddHingeJoint(PhalangesGameObjects[i],
                                               new Vector3(0, 0, 1), connectedBody);
                }

                _phalanges[i] = HandFactory.GetPhalange(PhalangesGameObjects[i], Index, i, DeviceType);
                PhalangesGameObjects[i].GetComponent <Rigidbody>().maxAngularVelocity = 100f;

                // Add limits to the hingejoints of the finger
                if (DeviceType == device_type_t.GLOVE_RIGHT)
                {
                    ChangeJointLimit(_joints[i], -10, 120);
                }
                else
                {
                    ChangeJointLimit(_joints[i], -120, 10);
                }
                PhalangesGameObjects[i] = holder;
            }
        }