Search Unity

  1. Unity 2019.1 beta is now available.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Unity 2018.3 is now released.
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Assets Water 2D Tool v1.7 - GPU based ripple Water, realistic buoyancy, water flow & animation

Discussion in 'Works In Progress' started by Nicrom, Feb 23, 2015.

  1. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    246

    Hello Everyone.
    With Water2D Tool you can quickly create dynamic 2D or 2.5D water for your game. This plugin allows you to make your 2D game more dynamic and engaging. The ability to animate the water can be used to create different puzzles and obstacles for the players.

    Water features
    • 2D and 2.5D water. The 2.5D water is similar to the one found in games like "The Cave" or "Rayman Legends".
    • Water flow that affects the objects in the water. You are able to specify a direction like: Left, Right, Up, Down or use an angle value.
    • 2 methods for simulating the Buoyant Force(This is what makes the objects float in the water):
      • Physics based buoyant force simulation that applies the Archimedes Principles. This makes the objects behavior more realistic in the water.
      • Linear Buoyant Force. Not very realistic, but very cheap in terms of performance.
    • The objects in the water can change it's total Area. The change is proportional to the area of the object that is submerged in the water.
    • 2 methods for animating the water:
      • Animation by object reference.
      • Animation by area offset.
    • Constant Area. If the width of the water is increasing the water height will decrease so that the initial water area does not change.
    • Texture Tiling. The UVs are recalculated every time the width or the height of the water mesh is changing. As a result there is no texture stretching. This is done in the Editor as well as at Run Time.
    • The ability to specify the pixels per unit for the texture.
    • Idle waves.
    • Works with 2D and 3D Colliders.

    You can click on objects to move them in the scene.

    Below are a couple of Gifs of Water2D Tool.

    Water Creation.


    Floating objects.
    Physics based Buoyant Force simulation.

    2.5D Water.

    Water flow.

    Area change by objects.


    Water animation and constant water Area.


    UV recalculation
    In the Gifs bellow the green and yellow rectangles are a single 512 x 512 px texture.



    Please tell me what do you think about this tool. What functions would you like to have besides the above?. You can contact me personally by email johnq002@gmail.com or follow me on Twitter.
    Thanks.
     
    Last edited: Jan 29, 2019
  2. Moeen

    Moeen

    Joined:
    May 4, 2014
    Posts:
    13
    That's really cool, I would buy it if it were priced fairly.
    It's great as it is but just some ideas:
    Perhaps a splash on impact, overflow if bounds are exceeded, just basically making it more like water. If you did things like that then the price I'd be willing to pay would go up :)
     
  3. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    246
    I'll probably add a splash a little further on the road. As for overflow, I am not sure I will add this option as it really hard to implement. Water2D is a tool for creating Static water with dynamic properties. Overflow is more in the fluid simulation domain.
     
  4. Moeen

    Moeen

    Joined:
    May 4, 2014
    Posts:
    13
    Yeah I get it, I thought it may be especially difficult to implement overflow but nonetheless this is a great extension.
     
  5. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,781
    Does this require Unity Pro to create?
    I guess a better question is why is it being created as an extension instead of a unity store asset?

    I think this could potentially address issues several recent projects have had. Pretty cool!
     
  6. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    246
    No, you do not need Unity Pro, it's all in Unity Free. I called it "Water2D Tool Editor Extension" because you use the Editor to change the width and height of the water, as you can see from the first Gif. When it's finished it will be published to the Asset Store. I guess I'll drop "Editor Extension" from the name and just call it "Water2D Tool". That will make it less confuzing.
     
    theANMATOR2b likes this.
  7. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    246
    Added a new option for generating water waves. When enabled will distort the surface of the water to simulate waves like the one created by the wind. Needs a little more work to make it look more realistic.

     
    Last edited: Apr 26, 2015
    Bridin likes this.
  8. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    246
    The past couple of weeks had been busy and could not work on this tool as much as I wanted.
    Here is a little update on the progress. Added a more realistic Buoyant Force (it's what makes the objects float in a fluid that has a lower density then the object) simulation, that takes into account the shape of the object and its mass. The initial Buoyant Force was calculated based on the objects position and did not take into account it's shape and mass and was not very realistic. Both will be included in the final version.
     
    Last edited: Jan 29, 2019
  9. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    246
    UPDATE: Added a new demo scene, a particle effect and a splash sound. If you use the last version of Google Chrome you probably won't be able to play the demo scene, so Paste the link in Internet Explorer or Firefox.
     
  10. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    246
    Made a small Preview video.

     
  11. lorenalexm

    lorenalexm

    Joined:
    Dec 14, 2012
    Posts:
    301
    Love seeing the updates as they come along, quite impressive work so far! Is this being programmed in C# or UnityScript, and secondly will the sources be provided with release or will the package be locked up in a DLL? Either way, I am looking forward to seeing this on the Asset Store.
     
    Nicrom likes this.
  12. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    246
    I'm glad you like it. The language is C#. The source code will be available with lots of comments. You will be able to change it if you want.
    Next I'll do some tutorials showing how to animate the water and other things.
    As for the release date, I hope it will be available on the Asset Store by the end of the next week if everything goes OK.
     
  13. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    246
    UPDATE: Created a couple of tutorials about some of the Water2D Tool features.

     
  14. joni-giuro

    joni-giuro

    Joined:
    Nov 21, 2013
    Posts:
    433
    This is SO cool!
     
    Nicrom likes this.
  15. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    246
    The Water2D Tool is finally released to the Asset Store. You can find it here Asset Store Link
     
  16. lorenalexm

    lorenalexm

    Joined:
    Dec 14, 2012
    Posts:
    301
    I'm glad to hear you were able to roll it out and get it on the Asset Store. You have my purchase secured in the very near future!
     
    Nicrom likes this.
  17. Too-Nerd-To-Die

    Too-Nerd-To-Die

    Joined:
    Apr 28, 2014
    Posts:
    44
    It is optimized for mobile?
     
  18. jeffweber

    jeffweber

    Joined:
    Dec 17, 2009
    Posts:
    510
    This looks nice. I've been working on something similar for my next game, but will take a look at yours as it appears to be further along.

    I've not watched the vids yet so I'll ask. Can you manually generate the waves. In my game I need waves that start small then get larger and more "fierce" as time goes on. Possible?

    Great job!
     
    Nicrom likes this.
  19. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    246
    To give you a little benchmark. I tested the demo scenes on 2 Android phones: a Samsung S4 and Sony Xperia J.
    Even if it's 2 years old the S4 is still a high end phone while the Sony Xperia J even at release was a low end phone.
    So here are the results:

    S4 - 60 fps with occasional drops to 58 fps.
    Xperia j - between 10 to 20 fps, that's something to be expected.

    Keep in mind that the demo scenes contain the most computer intensive features, like realistic buoyant force and animation. When I tested the scenes on the phones I used the same settings as on the PC. If you play a little with the water settings you could get a better performance.
     
    Last edited: May 21, 2015
    Too-Nerd-To-Die likes this.
  20. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    246
    At the moment this feature is not available, but I added it to my To Do list, so I'll try to implement it in the next updates.
     
  21. jeffweber

    jeffweber

    Joined:
    Dec 17, 2009
    Posts:
    510
    Thanks, Nicrom

    More follow-up questions:

    Are the waves simulated using springs? Would be nice to have programmatic access to the surface vertice heights so we can generate our own waves and wave patterns. :) I don't want to continuously control the heights, just want to be able to move them and release in order to generate different waves. Similar to what you seem to be doing when an object falls in the water.
     
  22. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    246
    Yes, I use springs to simulate the waves. Water2D Tool has 2 options for generating idle waves (waves created not by objects): The first is small waves in random places (you can customize them in the inspector to make them bigger) and second are waves generated by a number of overlapping sine waves. Both methods change the velocity of the surface vertices to achieve their effects. I want implement another method for idle waves. I'm not sure if it will be in the next update, but I hope I will implement it very soon.

    You could generate different patterns by changing the velocities of the surface vertices which are stored in a list in the Water2D_Simulation script.
     
    Last edited: May 21, 2015
  23. Sykoo

    Sykoo

    Joined:
    Jul 25, 2014
    Posts:
    1,395
    This looks amazing!
    Is there any type of tutorial for the line physics used for the top-side of the water?
     
  24. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    246
    Thanks. What do you mean by line physics?
     
  25. Too-Nerd-To-Die

    Too-Nerd-To-Die

    Joined:
    Apr 28, 2014
    Posts:
    44
    Unity 5 compatible?
     
  26. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    246
    Yes. At the beginning of the thread there is a WebGL demo link build in Unity 5.
     
    Last edited: May 22, 2015
  27. Too-Nerd-To-Die

    Too-Nerd-To-Die

    Joined:
    Apr 28, 2014
    Posts:
    44
    we can work in a way to use with sprite renderer?
     
  28. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    246
    Yes, the water is a mesh, but you can set in the Inspector the Sorting Layer and Order in Layer of the mesh so it will work with the sprites. You don't need Z positioning with the sprites, just use the Sorting Layer and Order in Layer.
     
    Last edited: May 22, 2015
  29. Too-Nerd-To-Die

    Too-Nerd-To-Die

    Joined:
    Apr 28, 2014
    Posts:
    44
    The object that I want to interact with the water has a sprite renderer, not a mesh renderer.
     
  30. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    246
    It doesn't mater if the object has a sprite, as I said, the water object has the option to set its Sorting Layer and Order in Layer the same way you can do for the sprites. Even I if the water is a mesh it will be sorted based on the layer you set in the Sorting Layer drop down menu. So you could place a sprite behind the water or in front of it by just changing the Sorting Layer of the sprite object.

    Take a look at this tutorial for the Water2D Tool, you can see in the Inspector The sorting Layer and Order in Layer options.
     
    Last edited: May 22, 2015
    Too-Nerd-To-Die likes this.
  31. Sykoo

    Sykoo

    Joined:
    Jul 25, 2014
    Posts:
    1,395
    Like whenever an item drops on the water, the 'line' pretty much reacts ike water. I wonder how this is achieved? :)
     
  32. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    246
    The basic ideas I took from this Tutorial.
     
  33. Sykoo

    Sykoo

    Joined:
    Jul 25, 2014
    Posts:
    1,395
    Thank you very much, I find the method for it very fascinating.
     
    Nicrom likes this.
  34. Too-Nerd-To-Die

    Too-Nerd-To-Die

    Joined:
    Apr 28, 2014
    Posts:
    44

    I could make it all work for the time being this normal functioning, thank you and congratulations for the asset.
     
    Nicrom likes this.
  35. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    246
    You welcome and Thanks :)
     
  36. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    246
    A little Update on the soon to be released Version 1.1 of Water2D Tool.
    • Added support for 3D Colliders.
    • A new option for the animation.
    • Code namespace to eliminate the likelihood of having clashes between classes.
     
    Last edited: Jun 21, 2015
    Too-Nerd-To-Die likes this.
  37. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    246
    Water2D Tool v1.1 is now live on Asste Store. Asset Store Link
    • Added support for 3D colliders.
    • Code namespace.
    • Added a new option in the animation group.
    • Now you can set the sorting layer and order in layer in the Inspector for the particle system and offset the position on the Z where the particle system will be instantiated.
    • The code was updated to Unity 5 API, so when you import the tool in a Unity 5.x project, Unity won't tell you that it needs to update the code. The code is the same for projects based on Unity 4.x and Unity 5.x.
     
    Too-Nerd-To-Die and LoDx like this.
  38. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    246
    This is a little preview of a new feature that will be available the the next update. Added a new option that simulates a better interaction of the objects with the surface waves.

    The new behavior.

    The old behavior.
     
    Too-Nerd-To-Die and theANMATOR2b like this.
  39. jeffweber

    jeffweber

    Joined:
    Dec 17, 2009
    Posts:
    510
    So is this new wave interaction using a true intersection between the water wave surface and the boat polygon and using that for buoyancy calcs? Or are you faking/simulating it somehow?

    Looks nice!
     
  40. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    246
    No, I am not faking it. Before, the intersection polygon was calculated using the Sutherland Hodgman polygon clipping algorithm. The problem with it was that it doesn't work well with nonconvex polygons. Because of that the clipping polygon was always a horizontal line(the water line) and the water waves had no affect on objects. Now I added a new clipping option that works with concave polygons as a result the behavior of the objects is influenced by the surface waves.
     
  41. jeffweber

    jeffweber

    Joined:
    Dec 17, 2009
    Posts:
    510
    Great. This is a feature I was seriously needing. What algo are you using now? Weiler-Atherton? When do you think the new version with this feature will be out??
     
  42. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    246
    I am using the clipper library. It may take a couple of weeks since I am working on a couple of other features for the 1.2 version. The current 1.2 alpha version works only with 2D colliders, If you don't need the 3D colliders, send me your invoice number by email and I'll send you the alpha version.
     
  43. jeffweber

    jeffweber

    Joined:
    Dec 17, 2009
    Posts:
    510
    I can wait. Plenty of other stuff to work on. :) Good to see progress on your asset.

    -Jeff
     
    Nicrom likes this.
  44. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    246
    Another feature that will be included in the 1.2 update is water flow.

     
    Too-Nerd-To-Die likes this.
  45. jeffweber

    jeffweber

    Joined:
    Dec 17, 2009
    Posts:
    510
    Did you ever add the ability to programmatically modify the waves... height, frequency, etc..? As mentioned in an earlier thread, my game needs to start with no waves then have the waves get progressively worse as time goes on.

    If so, what's the api look like?

    New flow feature looks cool.
     
  46. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    246
    The 1.1 version doesn't have the ability to change the amplitude, phase or speed of a wave at run time, but I will try to think of something for this version.
     
    biscito and Too-Nerd-To-Die like this.
  47. BTStone

    BTStone

    Joined:
    Mar 10, 2012
    Posts:
    1,027
    Hey Nicrom, I would like to contact you. Can't start a conversation here in Unity, I guess you disabled that feature. Can you give me a mail-adress? I have some specific questions for this Water 2D tool, if you don't mind :)
     
  48. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    246
    Hi. Sorry, I didn't know I had that feature disabled. My Email is johnq002@gmail.com
     
  49. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,464
    Can it work with 2D platformers packages ? It is possible to have characters swimming underwater ?
     
  50. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    246
    Water2D Tool works only with objects that have a RigidBody2D or RigidBody attached to them. I used the 2D Character Controller that unity provides, for testing and it worked without problems. How an object behaves in the water depends on it's mass and collider area. There some additional parameters you can customize, like the scale of the buoyant force that is applied to an object with the tag "Player" and an imaginary bounding box that will be used to calculate it's area.
     
    Last edited: Aug 6, 2015