Search Unity

2D Flow of water

Discussion in '2D' started by tiendung717, Aug 16, 2014.

  1. tiendung717

    tiendung717

    Joined:
    Aug 9, 2014
    Posts:
    5
  2. herman111

    herman111

    Joined:
    May 11, 2014
    Posts:
    119
    only thing I can think of is a scrolling texture or some kind of particle effect
     
  3. tiendung717

    tiendung717

    Joined:
    Aug 9, 2014
    Posts:
    5
    @herman111: I tried to use particle effect but Particle collision doesn't support Unity 2D. I need process collision between flow of water and some game object. Could you tell more about scrolling texture ?
     
  4. herman111

    herman111

    Joined:
    May 11, 2014
    Posts:
    119
    a texture that scrolls on a gameobject..add this code to a sprite with a texture
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class scrollingTexture : MonoBehaviour {
    5.  
    6.     public int materialIndex = 0;  
    7.     public Vector2 uvAnimationRate = new Vector2( 1.0f, 0.0f );  
    8.     public string textureName = "_MainTex";
    9.     Vector2 uvOffset = Vector2.zero;    
    10.    
    11.     void LateUpdate()     {      
    12.         uvOffset += ( uvAnimationRate * Time.deltaTime );
    13.         if( renderer.enabled ) {          
    14.             renderer.materials[ materialIndex ].SetTextureOffset( textureName, uvOffset );
    15.         }
    16.     }
    17. }
    18.  
     
  5. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    Do you need your water to swish and splash and respond to physics the way that game does? If so, that's going to be a major undertaking on its own. If not, herman's strategy could work.
     
  6. tiendung717

    tiendung717

    Joined:
    Aug 9, 2014
    Posts:
    5
    @StarManta: Yes, I need a flow of water to swish, splash and respond to physics like that game. Could you suggest me some ideas ?