Ejemplo n.º 1
0
        public void SetHandDiffs(bool _leftHand, Vector3 handPosition)
        {
            HandGrabPose closestHandPose = null;

            attachTransform = this.gameObject.transform;
            float lastDist = float.MaxValue;

            //get closest distance from hand
            foreach (HandGrabPose item in handGrabPoses.FindAll(p => p.leftHand == _leftHand))
            {
                Vector3 positionCompair = positionOfParent ? item.gameObject.transform.parent.position : item.gameObject.transform.position;
                item.SetDebugHand(false);
                float dist = Vector3.Distance(handPosition, positionCompair);
                if (dist < lastDist)
                {
                    closestHandPose = item;
                    lastDist        = dist;
                }
            }
            if (closestHandPose != null)
            {
                attachTransform = closestHandPose.GetAttachPoint();
                grabbingType    = closestHandPose.grabbingType;
                animateFrame    = closestHandPose.animateFrame;
                closestHandPose.SetDebugHand(true);
            }
            else
            {
                attachTransform = this.gameObject.transform;
                grabbingType    = grabbingType != GrabbingType.SimpleFingerTip ? GrabbingType.None : grabbingType;
                animateFrame    = 0f;
            }
        }
    public void CopyObject()
    {
        //create a copy of object ...
        GameObject copy = GameObject.Instantiate(this.gameObject, this.gameObject.transform.parent);
        //fix hand grasp pose ...
        HandGrabPose copyHandPose = copy.GetComponent <HandGrabPose>();

        copyHandPose.RemoveHandRef();
        //
    }