Exemplo n.º 1
0
    private void UpdateNet(Compound flowingCompound)
    {
        #region Net
        NetBall ball = Instantiate <NetBall>(m_netBallPrefab);
        Destroy(ball.gameObject, m_livingTime);

        Vector3 transformedFlowPoint = transform.position + TransformedVertex(m_flowPoint);
        ball.transform.position = transformedFlowPoint;
        ball.containedCompound  = flowingCompound;
        ball.creator            = this;
        ball.transform.LookAt(transformedFlowPoint - transform.up);

        #region Net - Connexion vers la prochaine balle

        if (!m_lastNetBall)
        {
            m_lastNetBall = ball;
        }
        else
        {
            NetWater waterNet = Instantiate <NetWater>(m_waterNetPrefab);
            waterNet.SetAttachments(m_lastNetBall.transform, ball.transform);
            waterNet.color = m_compound.color;
            waterNet.size  = m_bottomRadius * m_opening;

            m_lastNetBall = ball;
        }
        #endregion
        #endregion
    }
Exemplo n.º 2
0
    private void FlowNet(Vector3 flowCenter, float flowSize, Compound flowedCompound)
    {
        NetBall ball = Instantiate <NetBall>(m_netBallPrefab);

        Destroy(ball.gameObject, m_livingTime);
        ball.transform.position = flowCenter;
        ball.containedCompound  = flowedCompound;
        ball.creator            = this;

        float pressure = 0.5f - transform.forward.y / 2;

        pressure = Mathf.Log(10 * pressure * pressure + 1);

        ball.GetComponent <Rigidbody>().AddForce(transform.forward * 10 * pressure);
        pressure = Mathf.Max(Mathf.Min(pressure / Mathf.Log(11), 1), 0.1f);

        ball.transform.LookAt(transform.position - transform.forward);

        #region Net - Connexion vers la prochaine balle

        if (!m_lastNetBall)
        {
            m_lastNetBall = ball;
        }
        // Si on a deux gouttes à la suite, on dessine un filet d'eau.
        else
        {
            NetWater waterNet = Instantiate <NetWater>(m_waterNetPrefab);
            waterNet.SetAttachments(m_lastNetBall.transform, ball.transform);
            waterNet.color = m_compound.color;

            m_lastNetBall = ball;
            waterNet.size = flowSize;
        }

        #endregion
    }