Exemplo n.º 1
0
    void FixedUpdate()
    {
        Collider[] nearby = Physics.OverlapSphere(transform.position, m_attachTolerance);

        m_attachedHose = null;
        foreach (Collider c in nearby)
        {
            HoseEnd hose = c.GetComponent <HoseEnd>();
            if (hose != null && !hose.m_held && m_attachedHose == null)
            {
                hose.m_connectionJoint.connectedAnchor = transform.position;
                if (hose != null)
                {
                    hose.m_connectionJoint.xMotion = ConfigurableJointMotion.Locked;
                    hose.m_connectionJoint.yMotion = ConfigurableJointMotion.Locked;
                    hose.m_connectionJoint.zMotion = ConfigurableJointMotion.Locked;

                    m_attachedHose = hose;

                    Rigidbody hoseRb = hose.GetComponent <Rigidbody>();
                    if (hoseRb != null)
                    {
                        hoseRb.freezeRotation  = true;
                        hoseRb.angularVelocity = Vector3.zero;
                    }
                }

                break;
            }
        }

        if (m_attachedHose)
        {
            foreach (Collider c in nearby)
            {
                {
                    m_attachedHose.GetComponent <Rigidbody>().angularVelocity = Vector3.zero;
                    Packet packet = c.GetComponent <Packet>();
                    if (packet && packet.currentTansmission.source == m_port)
                    {
                        m_attachedHose.Send(packet);
                    }
                }
            }
        }
    }