public void Pickup()
    {
        // get nearest
        m_curentInteractible = GetNearestInteractible();

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

        //already held check
        if (m_curentInteractible.m_activeHand)
        {
            m_curentInteractible.m_activeHand.Drop();
        }

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

        m_joint.connectedBody = targetBody;

        //set active hand
        m_curentInteractible.m_activeHand = this;
        controllerModel.gameObject.SetActive(false);
    }
Exemple #2
0
 void RpcChangeItem(GameObject _item, GameObject _parent)
 {
     item = _item.GetComponent <Interactible>();
     item.transform.parent        = _parent.transform;
     item.transform.localPosition = -2.0f * Vector3.up;
     item.GetComponent <Interactible>().SetPosition(Vector3.zero);
 }
    public void Drop()
    {
        //null check
        if (!m_CurrentInte)
        {
            return;
        }
        //Apply Velocity
        Rigidbody targetBody = m_CurrentInte.GetComponent <Rigidbody>();

        targetBody.velocity        = m_Pose.GetVelocity();
        targetBody.angularVelocity = m_Pose.GetAngularVelocity();
        //Detach
        m_Joint.connectedBody = null;
        //Clear
        m_CurrentInte.m_ActiveHand = null;
        m_CurrentInte = null;
    }
    public void Drop()
    {
        //null check
        if (!m_curentInteractible)
        {
            return;
        }

        //apply velocity
        Rigidbody targetBody = m_curentInteractible.GetComponent <Rigidbody>();

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

        //detatch
        m_joint.connectedBody = null;

        //clear
        m_curentInteractible.m_activeHand = null;
        m_curentInteractible = null;
        controllerModel.gameObject.SetActive(true);
    }
    public void PickUp()
    {
        //get nearest
        m_CurrentInte = GetNearestInte();

        //null check
        if (!m_CurrentInte)
        {
            return;
        }
        //already held
        if (m_CurrentInte.m_ActiveHand)
        {
            m_CurrentInte.m_ActiveHand.Drop();
        }

        //position and rotation
        m_CurrentInte.transform.position = transform.position;
        m_CurrentInte.transform.rotation = transform.rotation;

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

        if (m_CurrentInte.name.Equals("Chisel"))
        {
            m_CurrentInte.gameObject.transform.parent = transform;
            targetBody.isKinematic = true;
        }
        else
        {
            m_Joint.connectedBody = targetBody;
        }

        //set active hand
        m_CurrentInte.m_ActiveHand = this;
    }