Exemplo n.º 1
0
    public void Pickup()
    {
        // Get nearest interactable
        currentInteractable = GetNearestInteractable();

        // Null check
        if (!currentInteractable)
        {
            return;
        }

        // check if kinematic or physics based
        if (currentInteractable.GetComponent <Rigidbody>().isKinematic)
        {
            currentInteractable.transform.parent = this.transform;
        }
        else
        {
            // Position
            currentInteractable.ApplyOffset(transform);

            // Attach
            Rigidbody targetBody = currentInteractable.GetComponent <Rigidbody>();
            joint.connectedBody = targetBody;
        }
        // Set active hand
        currentInteractable.activeHand = this;
        currentInteractable.OnPickup(this);
    }
Exemplo n.º 2
0
    public void Pickup()
    {
        // Get nearest interactable
        currentInteractable = GetNearestInteractable();

        // Null check
        if (!currentInteractable)
        {
            return;
        }

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

        // Position
        currentInteractable.ApplyOffset(transform);

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

        joint.connectedBody = targetBody;

        // Set active hand
        currentInteractable.m_ActiveHand = this;
        currentInteractable.OnPickup(this);
    }