Beispiel #1
0
    public void Drop()
    {
        // Null check
        if (!currentInteractable)
        {
            return;
        }

        // Method called before drop
        currentInteractable.OnDrop(this);

        // check if kinematic or physics based
        if (currentInteractable.GetComponent <Rigidbody>().isKinematic)
        {
            currentInteractable.transform.parent = null;
        }
        else
        {
            // Apply velocity
            Rigidbody targetBody = currentInteractable.GetComponent <Rigidbody>();
            targetBody.velocity        = pose.GetVelocity();
            targetBody.angularVelocity = pose.GetAngularVelocity();

            // Detach
            joint.connectedBody = null;
        }

        // Clear active hand
        currentInteractable.activeHand = null;
        currentInteractable            = null;
    }
Beispiel #2
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);
    }
Beispiel #3
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);
    }
Beispiel #4
0
    public void Drop()
    {
        // Null check
        if (!currentInteractable)
        {
            return;
        }

        // Method called before drop
        currentInteractable.OnDrop(this);

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

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

        // Detach
        joint.connectedBody = null;

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