Exemplo n.º 1
0
    void FixedUpdate()
    {
        if (grabbedObject != null)
        {
            bool fingersGrabbing = false;
            for (int i = 1; i < digits.Length; i++)
            {
                Finger finger = (Finger)digits[i];
                if (finger.hasGrabbed())
                {
                    fingersGrabbing = true;
                }
            }

            if (!fingersGrabbing)
            {
                GrabbedRigidbody grb = grabbedObject.GetComponent <GrabbedRigidbody>();
                grabbedRBfunc = grb;
                grb.Unkinematize();
                Destroy(grb);
                Destroy(go);

                grabbedObject    = null;
                grabbedRigidbody = null;
            }
        }
    }
Exemplo n.º 2
0
    void Grab(GameObject obj, Rigidbody rb)
    {
        Vector3 palmOffsetWorld = hand.transform.TransformDirection(palmOffset);

        GrabbedRigidbody grb = obj.AddComponent <GrabbedRigidbody>();

        grabbedRBfunc = grb;

        go = new GameObject();
        go.transform.parent        = hand.transform;
        go.transform.localPosition = Enscale(palmOffset, go.transform.localScale);
        if (whichHand == WhichHands.Right)
        {
            go.transform.localRotation = Quaternion.Euler(20, 270, 0);           // hack, depends on rigs hand axes, need to use norm axes
        }
        else
        {
            go.transform.localRotation = Quaternion.Euler(-20, 270, 180);           // hack, depends on rigs hand axes, need to use norm axes
        }
        grb.Kinematize(hand.transform, whichHand == WhichHands.Right, hand.transform.position + palmOffsetWorld, go);

        //GrabWithHinge(obj);
    }
Exemplo n.º 3
0
    void Grab(GameObject obj, Rigidbody rb)
    {
        Vector3 palmOffsetWorld = hand.transform.TransformDirection(palmOffset);

        GrabbedRigidbody grb = obj.AddComponent<GrabbedRigidbody>();
        grabbedRBfunc = grb;

        go = new GameObject();
        go.transform.parent = hand.transform;
        go.transform.localPosition = Enscale(palmOffset, go.transform.localScale);
        if (whichHand == WhichHands.Right)
            go.transform.localRotation = Quaternion.Euler(20,270,0); // hack, depends on rigs hand axes, need to use norm axes
        else
            go.transform.localRotation = Quaternion.Euler(-20,270,180); // hack, depends on rigs hand axes, need to use norm axes

        grb.Kinematize(hand.transform, whichHand == WhichHands.Right, hand.transform.position + palmOffsetWorld, go);

        //GrabWithHinge(obj);
    }
Exemplo n.º 4
0
    void FixedUpdate()
    {
        if (grabbedObject != null) {
            bool fingersGrabbing = false;
            for (int i = 1; i < digits.Length; i++) {
                Finger finger = (Finger) digits[i];
                if (finger.hasGrabbed())
                    fingersGrabbing = true;
            }

            if (!fingersGrabbing) {
                GrabbedRigidbody grb = grabbedObject.GetComponent<GrabbedRigidbody>();
                grabbedRBfunc = grb;
                grb.Unkinematize();
                Destroy(grb);
                Destroy(go);

                grabbedObject = null;
                grabbedRigidbody = null;
            }
        }
    }