예제 #1
0
    // Pick up the object, or drop it if it is already being held
    public void Interact(FPSWeapon script)
    {
        // Is the object currently being held?
        if (m_Held)
        {
            script.PlayAnim("v_portalgun.qc_skeleton|release");
            Drop();
        }
        else
        {
            script.PlayAnim("v_portalgun.qc_skeleton|pickup");
            script.holding             = true;
            m_Held                     = true;
            m_ThisRigidbody.useGravity = false;

            m_HoldJoint = script.m_HandTransform.gameObject.AddComponent <FixedJoint>();
            //m_HoldJoint.breakForce = 10000f; // Play with this value
            m_HoldJoint.breakForce    = 5000f;
            m_HoldJoint.connectedBody = m_ThisRigidbody;
        }
    }
예제 #2
0
    // Throw the object
    public void Action(FPSWeapon script)
    {
        // Is the object currently being held?
        if (m_Held)
        {
            script.PlayAnim("v_portalgun.qc_skeleton|release");
            Drop();

            // Force the object away in the opposite direction of the player
            Vector3 forceDir = transform.position - script.m_HandTransform.position;
            m_ThisRigidbody.AddForce(forceDir * script.m_ThrowForce);
        }
    }