Exemple #1
0
        private void LateUpdate()
        {
            if (m_fluid)
            {
                Vector3 currentPosition = transform.position;
                if (m_speed != Vector3.zero)
                {
                    if (m_tempCol == null)
                    {
                        m_tempCol = m_fluid.GetComponent <Collider>();
                    }
                    if (m_tempRend == null)
                    {
                        m_tempRend = m_fluid.GetComponent <Renderer>();
                    }

                    ray = new Ray(currentPosition, Vector3.forward);
                    if (m_tempCol.Raycast(ray, out hitInfo, 10))
                    {
                        fWidth  = m_tempRend.bounds.extents.x * 2f;
                        fRadius = (GetRadius() * m_fluid.GetWidth()) / fWidth;
                        m_fluid.AddVelocity(hitInfo.textureCoord, -m_speed, fRadius);
                    }
                }
            }
        }
Exemple #2
0
        private void ManipulateParticles()
        {
            if (Input.GetMouseButton(0) || m_alwaysOn)
            {
                Debug.Log("0");
                m_mousePos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0f);
                ray        = Camera.main.ScreenPointToRay(m_mousePos);
                if (m_tempCol.Raycast(ray, out hitInfo, 100))
                {
                    fWidth  = m_tempRend.bounds.extents.x * 2f;
                    fRadius = (m_particlesRadius * m_fluid.GetParticlesWidth()) / fWidth;
                    m_fluid.AddParticles(hitInfo.textureCoord, fRadius, m_particlesStrength * Time.deltaTime);
                }
            }
            if (Input.GetMouseButton(1) || m_alwaysOn)
            {
                Debug.Log("1");
                m_mousePos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0f);
                ray        = Camera.main.ScreenPointToRay(m_mousePos);
                if (m_tempCol.Raycast(ray, out hitInfo, 100))
                {
                    Debug.Log("1 - raycast");
                    direction = new Vector3(1.0f, 0.0f, 0.0f);
                    direction = direction * m_velocityStrength * Time.deltaTime;
                    fWidth    = m_tempRend.bounds.extents.x * 2f;
                    fRadius   = (m_velocityRadius * m_fluid.GetWidth()) / fWidth;

                    if (Input.GetMouseButton(0))
                    {
                        Debug.Log("1 - added velocity");
                        m_fluid.AddVelocity(hitInfo.textureCoord, -direction, fRadius);
                        Debug.Log(direction);
                    }
                    else
                    {
                        m_fluid.AddVelocity(hitInfo.textureCoord, direction, fRadius);
                    }
                }
            }
        }
Exemple #3
0
 private void LateUpdate()
 {
     for (int i = 0; i < Input.touchCount; ++i)
     {
         touch = Input.GetTouch(i);
         ray   = Camera.main.ScreenPointToRay(new Vector3(touch.position.x, touch.position.y, 0f));
         if (m_tempCol.Raycast(ray, out hitInfo, 100))
         {
             fWidth  = m_tempRend.bounds.extents.x * 2f;
             fRadius = (m_particlesRadius * m_fluid.GetParticlesWidth()) / fWidth;
             m_fluid.AddParticles(hitInfo.textureCoord, fRadius, m_particlesStrength * Time.deltaTime);
             if (touch.phase == TouchPhase.Moved)
             {
                 direction = new Vector3(touch.deltaPosition.x, touch.deltaPosition.y) * m_velocityStrength * touch.deltaTime;
                 fWidth    = m_tempRend1.bounds.extents.x * 2f;
                 fRadius   = (m_velocityRadius * m_fluid.GetWidth()) / fWidth;
                 m_fluid.AddVelocity(hitInfo.textureCoord, direction, fRadius);
             }
         }
     }
 }