Пример #1
0
    public void Drop()
    {
        if (!m_CurrentInteractable)
        {
            return;
        }

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

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

        m_Joint.connectedBody = null;

        if (m_CurrentInteractable.gameObject.GetComponent <PartScript>() != null)
        {
            m_CurrentInteractable.gameObject.GetComponent <PartScript>().grabbedByHand = false;
        }

        if (m_CurrentInteractable.gameObject.GetComponent <HammerScript>() != null)
        {
            m_CurrentInteractable.gameObject.GetComponent <HammerScript>().InHand = false;
        }

        m_CurrentInteractable.m_ActiveHand = null;
        m_CurrentInteractable = null;
    }
Пример #2
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (col.tag == INTERACTABLE_TAG)
        {
            // Temp ========================
            if (m_targetInteractible != null)
            {
                SpriteRenderer otherSr = m_targetInteractible.GetComponent <SpriteRenderer>();
                otherSr.color = Color.gray;
            }
            SpriteRenderer sr = col.GetComponent <SpriteRenderer>();
            sr.color = Color.green;
            // =============================

            m_targetInteractible = col.GetComponent <InteractableScript>();
            interactText.SetActive(true);
        }
    }
Пример #3
0
    public void Pickup()
    {
        m_CurrentInteractable = GetNearestInteractable();

        if (!m_CurrentInteractable)
        {
            return;
        }

        HoldingSomething = true;
        if (m_CurrentInteractable.m_ActiveHand)
        {
            m_CurrentInteractable.m_ActiveHand.Drop();
        }

        if (m_CurrentInteractable.gameObject.GetComponent <PartScript>() != null)
        {
            m_CurrentInteractable.gameObject.GetComponent <PartScript>().grabbedByHand = true;
        }

        if (m_CurrentInteractable.gameObject.GetComponent <HammerScript>() != null)
        {
            m_CurrentInteractable.gameObject.GetComponent <HammerScript>().InHand = true;
        }

        if (m_CurrentInteractable.gameObject.GetComponent <RestartCubeScript>() != null)
        {
            m_CurrentInteractable.gameObject.GetComponent <RestartCubeScript>().restart = true;
        }

        m_CurrentInteractable.transform.position = transform.position;

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

        m_Joint.connectedBody = targetBody;

        m_CurrentInteractable.m_ActiveHand = this;
    }