Ejemplo n.º 1
0
    public void PickUp()
    {
        //Get nearest
        m_CurrentInteractable = GetNearestInteractable();

        //Null Ckeck (mirar si realment tenim algo que agafar)
        if (!m_CurrentInteractable) //comproba si es null
        {
            return;
        }

        //Already held, check (Si tenim algo que agafar, si ho te un altre controler, fer que el altre ho solte i este ho agafe)

        if (m_CurrentInteractable.m_ActiveHand) //si te una ma ja agafantlo
        {
            m_CurrentInteractable.m_ActiveHand.Drop();
        }

        //Position

        //m_CurrentInteractable.transform.position = transform.position; //si lo hacemos de la forma basica (la version que no hacemos acciones)

        m_CurrentInteractable.ApplyOffset(transform);

        //attach

        Rigidbody targetBody = m_CurrentInteractable.GetComponent <Rigidbody>();

        m_Joint.connectedBody = targetBody;

        //set active hand

        m_CurrentInteractable.m_ActiveHand = this;
    }
    public void Pickup()
    {
        //get nearest interactable
        m_CurrentInteractable = GetNearestInteractable();

        // null check
        if (!m_CurrentInteractable)
        {
            return;
        }

        // Already Held, check
        if (m_CurrentInteractable.m_ActiveHand)
        {
            m_CurrentInteractable.m_ActiveHand.Drop();
        }

        // position to controller
        m_CurrentInteractable.ApplyOffset(transform);

        // attach
        Rigidbody targetBody = m_CurrentInteractable.GetComponent <Rigidbody>();

        m_Joint.connectedBody = targetBody;

        // Set active Hand
        m_CurrentInteractable.m_ActiveHand = this;
    }
Ejemplo n.º 3
0
    public void PickUp()
    {
        // Get nearest
        currentInteractable = GetNearestInteractable();

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

        // Already Held check
        if (currentInteractable.activeHand)
        {
            currentInteractable.activeHand.Drop();
        }

        // Position to controller
        currentInteractable.ApplyOffset(transform);

        // Attach rigid body to the joint
        Rigidbody targetBody = currentInteractable.GetComponent <Rigidbody>();

        joint.connectedBody = targetBody;

        // Set Active Hand variable
        currentInteractable.activeHand = this;
    }
Ejemplo n.º 4
0
    public void PickupObject()
    {
        currentInteractableObject = NearestObject();

        if (currentInteractableObject == null)
        {
            return;
        }

        //provjeravamo da li je objekt u ruci
        if (currentInteractableObject.ActiveHand)
        {
            //bacamo objekt prije nego ga prebacimo u drugu ruku
            currentInteractableObject.ActiveHand.DropObject();
        }


        currentInteractableObject.ApplyOffset(transform);

        //dohvacamo rigidbody i zakacimo ga za fixed joint
        Rigidbody target = currentInteractableObject.GetComponent <Rigidbody>();

        fixedJoint.connectedBody = target;

        currentInteractableObject.ActiveHand = this;
    }
Ejemplo n.º 5
0
    public void PickUp()
    {
        //Obtener interactable mas cercano
        m_currentInteractable = GetNearestInteractable();

        //Verificar que no sea null
        if (!m_currentInteractable)
        {
            return;
        }

        //Que no este sujetado por otra mano
        if (m_currentInteractable.m_activeHand)
        {
            m_currentInteractable.m_activeHand.Drop();
        }

        //Establecer position del objeto
        //m_currentInteractable.transform.position = transform.position;
        m_currentInteractable.ApplyOffset(transform);

        //Agregar como cuerpo conectado al joint de la mano
        Rigidbody targetBody = m_currentInteractable.GetComponent <Rigidbody>();

        m_joint.connectedBody = targetBody;

        //Establecer active hand en interactable
        m_currentInteractable.m_activeHand = this;
    }
Ejemplo n.º 6
0
    public void Pickup()
    {
        // Get nearest interactable
        m_CurrentInteractable = GetNearestInteractable();
        // Null check
        if (!m_CurrentInteractable)
        {
            return;
        }
        // Heavy obj check
        if (m_CurrentInteractable.gameObject.CompareTag("Heavy"))
        {
            // If the other hand is not hovering over the same obj
            if (otherController.GetComponent <Hand>().m_ContactInteractables.IndexOf(m_CurrentInteractable) < 0)
            {
                return;
            }
        }
        // Already held, check
        if (m_CurrentInteractable.m_ActiveHand && m_CurrentInteractable.gameObject.CompareTag("Interactable"))
        {
            m_CurrentInteractable.m_ActiveHand.Drop();
            m_CurrentInteractable.GetComponent <ColorManager>().changeToBlue();
        }
        // Position
        // m_CurrentInteractable.transform.position = transform.position;
        m_CurrentInteractable.ApplyOffset(transform);
        // Attach
        Rigidbody targetBody = m_CurrentInteractable.GetComponent <Rigidbody>();

        m_Joint.connectedBody = targetBody;
        if (m_CurrentInteractable.gameObject.CompareTag("Heavy"))
        {
            otherController.GetComponent <Hand>().m_Pose.enabled = false;
        }
        // Set active hand
        m_CurrentInteractable.m_ActiveHand = this;
        // Change color
        if (m_CurrentInteractable.gameObject.CompareTag("Flask"))
        {
            m_CurrentInteractable.GetComponent <ColorManager>().changeToClear();
        }
        else
        {
            m_CurrentInteractable.GetComponent <ColorManager>().changeToBlue();
        }
    }
Ejemplo n.º 7
0
    // The interactable is attached to the hand
    public void Pickup()
    {
        currentInteractable = GetNearestInteractable();

        // Already Held Check
        if (currentInteractable && currentInteractable.activeHand)
        {
            currentInteractable.activeHand.Drop();
        }

        // Grabbed Check
        if (currentInteractable)
        {
            // Position
            currentInteractable.ApplyOffset(transform);

            // Might be Bugged?
            if (currentInteractable.sizeDown)
            {
                currentInteractable.transform.localScale -= currentInteractable.sizeDownAmount;
            }

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

            // Set Active Hand
            currentInteractable.activeHand = this;

            if (currentInteractable.GetComponent <Collider>())
            {
                currentInteractable.GetComponent <Collider>().enabled = false;
            }
        }
        else
        {
            return;
        }
    }
Ejemplo n.º 8
0
    public void Pickup()
    {
        // Get nearest interactable
        m_CurrentInteractable = GetNearestInteractable();
        // Null check
        if (!m_CurrentInteractable)
        {
            return;
        }
        // Heavy obj check
        if (m_CurrentInteractable.gameObject.CompareTag("Heavy"))
        {
            // If the other hand is not hovering over the same obj
            if (otherController.GetComponent <Hand>().m_ContactInteractables.IndexOf(m_CurrentInteractable) < 0)
            {
                return;
            }
        }
        // Already held, check
        if (m_CurrentInteractable.m_ActiveHand && m_CurrentInteractable.gameObject.CompareTag("Interactable"))
        {
            m_CurrentInteractable.m_ActiveHand.Drop();
            m_CurrentInteractable.GetComponent <ColorManager>().changeToBlue();
        }
        // Tyvex
        if (m_CurrentInteractable.gameObject.CompareTag("Tyvex"))
        {
            m_CurrentInteractable.gameObject.SetActive(false);
            m_Player.NextStep();
            return;
        }
        // OpenButton
        if (m_CurrentInteractable.gameObject.CompareTag("OpenButton"))
        {
            m_CurrentInteractable.gameObject.SetActive(false);
            // Play animation
            m_Animator.Play("Open", -1, 0f);
            m_Player.NextStep();
            return;
        }
        // CloseButton
        if (m_CurrentInteractable.gameObject.CompareTag("CloseButton"))
        {
            m_CurrentInteractable.gameObject.SetActive(false);
            // Reverse animation play
            m_Animator.SetFloat("Direction", -1.0f);
            m_Animator.Play("Open", -1, float.NegativeInfinity);
            m_Player.NextStep();
            return;
        }
        // Position
        // m_CurrentInteractable.transform.position = transform.position;
        m_CurrentInteractable.ApplyOffset(transform);
        // Attach
        Rigidbody targetBody = m_CurrentInteractable.GetComponent <Rigidbody>();

        m_Joint.connectedBody = targetBody;
        if (m_CurrentInteractable.gameObject.CompareTag("Heavy"))
        {
            otherController.GetComponent <Hand>().m_Pose.enabled = false;
        }
        // Set active hand
        m_CurrentInteractable.m_ActiveHand = this;
        // Change color
        if (m_CurrentInteractable.gameObject.CompareTag("Flask"))
        {
            m_CurrentInteractable.GetComponent <ColorManager>().changeToClear();
        }
        else
        {
            m_CurrentInteractable.GetComponent <ColorManager>().changeToBlue();
        }
    }