public void Grab(Rigidbody r, GrabPoint g = null, bool forced = false)
        {
            if (r == null)
                return;

            //Debug.Log("Grab " + r.gameObject);

            m_wantsToPoint = false; // stop pointing when grabbing

            if (g == null)
            {
                m_held = r;
                m_joint = transform.gameObject.AddComponent<FixedJoint>();

                m_joint.autoConfigureConnectedAnchor = true;
                m_joint.connectedBody = m_held;

                return;
            }

            m_held = r;
            m_grab = g;
            m_grab.HandControl = this;

            if (m_AvatarAnimator != null)
            {
                m_AvatarAnimator.SetBool("Drop" + (m_hand == Hand.RIGHT ? "Right" : "Left"), false);
                m_AvatarAnimator.SetBool(m_grab.m_animationTransition + (m_hand == Hand.RIGHT ? "Right" : "Left"), true);
            }

            m_joint = transform.gameObject.AddComponent<FixedJoint>();

            m_held.isKinematic = true;

            Quaternion bindRot = Quaternion.Inverse(m_grab.GrabRotation(m_hand)) * r.transform.rotation;

            Vector3 pos = r.transform.position;
            Quaternion rot = r.transform.rotation;

            r.transform.rotation = m_sensor.rotation * bindRot;
            r.transform.position += m_sensor.position - m_grab.GrabPosition(m_hand);

            m_held.transform.parent = transform;

            targetPos = r.transform.localPosition;
            targetRot = r.transform.localRotation;

            if (!forced)
            {
                r.transform.position = pos;
                r.transform.rotation = rot;
            }
            else
            {
                m_AvatarAnimator.SetBool("Drop" + (m_hand == Hand.RIGHT ? "Right" : "Left"), false);
            }

            m_forced = forced;
        }
        public void Drop()
        {
            if (m_held == null)
                return;

            m_held.transform.parent = null;
            m_held.isKinematic = false;

            if (m_grab != null)
            {
                if (m_basicHand.gameObject.activeSelf)
                {
                    m_basicHand.SetBool(m_grab.m_animationTransition, false);
                    m_basicHand.SetBool("Fist", true);
                }

                else if (m_AvatarAnimator != null)
                {
                    m_AvatarAnimator.SetBool(m_grab.m_animationTransition + (m_hand == Hand.RIGHT ? "Right" : "Left"), false);
                    m_AvatarAnimator.SetBool("Drop" + (m_hand == Hand.RIGHT ? "Right" : "Left"), true);
                }

                m_grab.HandControl = null;
            }
            else if (m_joint != null)
            {
                Destroy(m_joint);
            }

            if (!float.IsNaN(velocity.x) && !float.IsNaN(velocity.y) && !float.IsNaN(velocity.z))
                m_held.AddForce(velocity, ForceMode.VelocityChange);

            if (!float.IsNaN(spin.x) && !float.IsNaN(spin.y) && !float.IsNaN(spin.z))
                m_held.AddTorque(spin, ForceMode.VelocityChange);

            m_held = null;
            m_joint = null;
            m_grab = null;
            m_forced = false;
        }