Esempio n. 1
0
    public void Pickup()
    {
        // Get nearest
        m_CurrentInterectable = GetNearestInterectable();

        // Null Check
        if (!m_CurrentInterectable)
        {
            return;
        }

        // Already held, check
        if (m_CurrentInterectable.m_ActiveHand)
        {
            m_CurrentInterectable.m_ActiveHand.Drop();
        }

        // Position
        m_CurrentInterectable.transform.position = transform.position;

        // Attach
        Rigidbody targetBody = m_CurrentInterectable.GetComponent <Rigidbody>();

        m_Joint.connectedBody = targetBody;

        // Set active hand
        m_CurrentInterectable.m_ActiveHand = this;
    }
Esempio n. 2
0
    public void Drop()
    {
        // Null check
        if (!m_CurrentInterectable)
        {
            return;
        }

        // Apply velocity
        Rigidbody targetBody = m_CurrentInterectable.GetComponent <Rigidbody>();

        targetBody.velocity        = m_Pose.GetVelocity();
        targetBody.angularVelocity = m_Pose.GetAngularVelocity();

        // Detach
        m_Joint.connectedBody = null;

        // Clear
        m_CurrentInterectable.m_ActiveHand = null;
        m_CurrentInterectable = null;
    }