Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

Assets Dynamic Water Physics - Realistic. Fast. Universal.

Discussion in 'Works In Progress' started by NWHCoding, Apr 21, 2017.

?

Which water asset do you use with DWP?

  1. Crest

    2 vote(s)
    28.6%
  2. AQUAS

    3 vote(s)
    42.9%
  3. RAM

    1 vote(s)
    14.3%
  4. Ocean Community Next Gen

    0 vote(s)
    0.0%
  5. Ceto

    0 vote(s)
    0.0%
  6. SUIMONO

    0 vote(s)
    0.0%
  7. Ultimate Water System

    0 vote(s)
    0.0%
  8. Other Flat Water Asset

    0 vote(s)
    0.0%
  9. Other Water Asset With Waves

    1 vote(s)
    14.3%
  1. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    686
    [UPDATE] DWP has been released and is now available on the Unity Asset Store: Unity Asset Store.

    This is a WIP forum, for the release version check this link.


    Simulation is based on object's mesh which eliminates need for tweaking based on object shape and makes is suitable for wide range of applications - from boats, ships, vehicles or anything that has a mesh. It works with both static and dynamic objects so it is possible to use it with e.g. raceboat.

    To make it mobile-friendly for larger meshes I built in mesh decimator, rasterizer and convex mesh generator. All 3 are optional.

    Works with any water system that can provide water height at a requested location.

    Tech Demo for the v1.0:


    [OLDER PRE-RELEASE VIDEOS]
    Here is a video from some time ago demonstrating dropping 1000 cubes into water (which in this case is just a Unity Water plane):


    Another video simulating a cruiser Queen Mary 2 using Ocean Community Next Gen to generate waves:



    That's it for now. Need to polish some things and in a month or so it will be ready for publishing.
    Ideas, recommendations and suggestions are always welcome and help a lot :)
     
    Last edited: Jun 16, 2017
  2. mike_kennedy989

    mike_kennedy989

    Joined:
    Feb 5, 2014
    Posts:
    51
    Sweet :) Looking forward to grabbing this at some point if we do something other than lakes :)
     
  3. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    1,999
    looks great and just what I need for my boat simulator. Purchased!
     
  4. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    686
    Hope it meets your expectations. If you need any help send me a mail to the address on the publisher site, I usually respond within an hour or so.
     
    derkoi likes this.
  5. DungTQ

    DungTQ

    Joined:
    Dec 27, 2016
    Posts:
    6
    how to create waves as high as in the last movie
     
  6. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    686
    As mentioned both in the video and in the first post, that was a demo video of using this asset with another (free) asset called "Ocean Community Next Gen" that is available here: https://github.com/eliasts/Ocean_Community_Next_Gen

    DWP is not a water asset, but rather water physics one and as such does not generate waves itself but can be used with water packages such as the Ocean Community mentioned above.
     
  7. DungTQ

    DungTQ

    Joined:
    Dec 27, 2016
    Posts:
    6
    Can you sen to me the project which which combines this asset and "Ocean Community Next Gen"?
    Many thanks!
     
  8. DungTQ

    DungTQ

    Joined:
    Dec 27, 2016
    Posts:
    6
     

    Attached Files:

  9. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    686
    Instead of sending you the folder here is a guide specifically for the Ocean Community Next Gen. Setting up for use with other water systems is already in the included documentation but this is more specific for this package:

    Guide for using DWP with Ocean Community Next Gen
    1. Download Ocean Community Next Gen from https://github.com/eliasts/Ocean_Community_Next_Gen
    2. Copy folder "Ocean" into your assets
    3. Remove the "Environment/Water" from the scene. I am assuming you are using the demo scene provided with DWP.
    4. Drag the "Ocean" prefab from "Ocean/Prefabs" into the scene.
    5. Change the tag of ocean to "Water".
    6. Set the Target of your ocean to your boat (in this case "Racer"). You will now be able to see the ocean and objects will float, but will ignore waves. You can play with ocean settings to make it look the way you like. I would recommend turning "Spread Along Frames" off to make it look smoother.
    7. Edit the WaterInterface.cs script as per explanation in the script itself and attach it to "Ocean" object in the editor.

    I could have sent you the finished product but I think this should help you and anyone else who wants to do it - this is explained in the documentation, but more in general. If you still want the project folder I can still send it to you (contact me over PM or email for that). Attached to this post is the already modified WaterInterface.cs script (only 3 lines changed).

    You might want to play with Ocean settings a bit to get the best visual result, I myself find that it has too much foam by default. Also, there are a few water height provided in the Ocean Community Next Gen and I found that GetHeightAtLocationChoppy2() works the best. You can try the others and see for yourself, they are located in the Ocean.cs script.

    The explanation above will work for other systems with waves too, you will just need to change "Ocean" to whatever your type is, and use the water height function that is provided with your system.

    P.S. forgot to mention that you shoud disable or remove any Water FX script that is active as it only works with flat water.
     

    Attached Files:

  10. DungTQ

    DungTQ

    Joined:
    Dec 27, 2016
    Posts:
    6
    Many thanks for your help!
     
  11. DungTQ

    DungTQ

    Joined:
    Dec 27, 2016
    Posts:
    6
    Dear!
    I have tried to do as you guide but have err at step 2
    upload_2017-6-27_9-45-11.png
    Cand you send to me the finished product?
    my email: quangdungtr@gmail.com
    PS: I'm using Unity 5.6
    Thanks a lot!
     
  12. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    686
    Vheck out your email for the complete, set-up project folder.

    I am not sure why you would get an error importing an asset into Unity. Make sure that you import only the Ocean folder from Assets, not the whole folder as it contains all the temp and project files that are not needed.
     
  13. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    686
    I have resent you the message. Check the spam folder, maybe it ended there since it has pictures and a lot of links (and it is a bit longer). I also sent you a completed project.

    What seems to be your problem is skipping step 7. and not attaching the modified WaterInterface.cs to ocean object.

    Please use publisher email or PM for support. Thank you.
     
  14. vertigostudios

    vertigostudios

    Joined:
    Oct 1, 2012
    Posts:
    92
    Hi I purchased the DWP yesterday and thought it would work nicely with suimono 2.0 Interactive water system.

    After a few hours I had no joy and was unable to get them both to work.

    So my question is, are they able to work together ?
     
  15. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    686
    Considering that they are advertising some kind of buoyancy system it should, but I can not tell you for sure since I do not have it. If you want me to try and set it up email or PM me a simple set up scene with the object in question and I will check it out. Sorry for the inconvenience.
     
  16. vertigostudios

    vertigostudios

    Joined:
    Oct 1, 2012
    Posts:
    92
    Hi again.

    After more testing, I'm now happy with the DWP reacts to the water. My latest tests was used with the Aquas Pro water/river set and I'm very pleased how easily it came together.

    Food for thought regarding any future updates, it would be a great feature to add water dispersion around the front of the boats.

    I noticed in the promo video that your using the wake effects, for some reason It doesn't want to play.

    I simply loaded up the demo scene for Aquas Pro, change the water plane tag to Water and dropped in the speed boat. The water FX script is present and ticked.

    Thanks again for your time. This is one hell of a asset and Im really please in the direction its going.
     
  17. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    686
    Glad you managed to solve it :)
    This is still v1.0 so there might be some rough edges. I always wait a bit to get some feedback before pushing out the next version (except for bug fixes) so your input is really helpful :).
    As for the water effects - you probably need to assign textures (this is the only thing that is not filled in automatically). I would recommend copying the default values or using something similar as described in the manual.
     
  18. vertigostudios

    vertigostudios

    Joined:
    Oct 1, 2012
    Posts:
    92
    I'll collect a list of possible and probable future features if that's alright.
     
  19. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    161
  20. Evgenius

    Evgenius

    Joined:
    Sep 4, 2013
    Posts:
    11
    I'm also wondering if it works with AQUAS... And how good is performance while using HTC Vive VR headset?
     
  21. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    161
    Holidays??
     
  22. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    161
    Obviously, the speed of response is not one of its great values.
     
  23. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    686
    Sorry for the wait time. I respond to the email within a few hours but Unity Forums apparently decided to not notify me in any way about any activity on this thread, not even alerts up at the top which I check daily. I am really sorry for that - and no holidays by the way. You may also check my activity on the Wheel Controller 3D thread and you will se that I was active all this time. I also PMed your my Activity feed for the forum lacking any activity info despite the thread being watched. Seems like a bug to me.

    Since it has a simple buoyancy feature built in, it will work with the asset. I cannot check and be sure 100% since I do not own it, but if it turns it does not I can offer a refund.

    Sorry once again for the wait - I would also suggest that you contact me over publisher mail in the future as your will get response as soon I get notification on my phone.

    Regards,
    Aron
     
    Last edited: Aug 15, 2017
  24. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    161

    Thank you, Aron. Everything cleared up. These things happen with the technologies. I hope I can buy your products soon.

    Regards.
     
  25. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    686
    I got alerted this time :)
     
  26. ZealousAppex

    ZealousAppex

    Joined:
    May 3, 2015
    Posts:
    13
    Will this work with PlayWater?
    Will this work with VR and if so wold it be as simple as adding a child to the boat and interacting with the wheel and throttle and pass the rotation value back to some class?
     
  27. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    686
    Yes, it will work with VR as all the physics is done through the rigidbody and forces. ShipController script that is included is very simple script that takes input from axes and calculates force and rudder rotation from it. So in short, yes you can add wheel and modify current script to receive values or make a new ship controller script since physics script is fully independent from ship controller.

    As for PlayWay - it should work and I have tested it BUT PlayWay (both asset store and beta version) have a quite serious bug meaning you cannot get water height, or better said you get it but it seems random at times. I was in contact with author of PlayWay Water but ever since I brough up the issue with water height he has gone silent and does not respond. If he fixes the water height function to return the correct values then yes, it does work. You can PM me for the WaterInterface.cs script for PlayWay, or modify it per included manual. Whichever you like.
     
  28. terlehu

    terlehu

    Joined:
    Oct 8, 2017
    Posts:
    1
    Just purchased. Will package work with Hydroform?
     
  29. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    686
    I have just sent the developer of Hydroform a mail and will be able to inform you after I get the response. There is no mention of ability to get water height at point and that is something that is needed. Most water assets appear to have that ability but I am not going to assume.
     
  30. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    686
    Just tested and DWP works with Ceto ocean out of the box and quite well.

    Here is the WaterInterface.cs script for Ceto (as per manual):

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using Ceto;
    5.  
    6. public class WaterInterface : MonoBehaviour {
    7.  
    8.     public Ocean ocean;
    9.  
    10.     private void Start()
    11.     {
    12.         ocean = GetComponent<Ocean>();
    13.     }
    14.  
    15.     public float GetWaterHeightAtLocation(float x, float z)
    16.     {
    17.         return ocean.QueryWaves(x, z);
    18.     }
    19. }
     
  31. DCrosby

    DCrosby

    Joined:
    Jan 13, 2013
    Posts:
    86
    Here is the WaterInterface.cs for UltimateWaterSystem (Which is based on PlayWay, but has a lot of the bugs allready mentioned fixed, and from the results, I see that water height seems to be one of them). :

    Code (CSharp):
    1.  
    2.  
    3. using System.Collections;
    4. using System.Collections.Generic;
    5. using UnityEngine;
    6. using UltimateWater;
    7. /// <summary>
    8. /// Attach this script to your non-flat water system.
    9. /// </summary>
    10. public class WaterInterface : MonoBehaviour {
    11.    // Replace "WaterSystem" with your type.
    12.    public Water myWaterSystem;
    13.    private WaterSample waterSample;
    14.    private Vector3 currentWaterLevel;
    15.    private Vector3 currentWaterForces;
    16.    public float waterHeight;
    17.    private void Start()
    18.    {
    19.        // Ultimate Water System
    20.        myWaterSystem = GetComponent<Water>();
    21.        waterSample = new WaterSample(myWaterSystem, WaterSample.DisplacementMode.HeightAndForces, 1.0f);    
    22.        // Hack to let Ultimate Water Wake Up, otherwise it throws an error it can't find water.
    23.        Invoke("StartWaterSampling", 0.5f);    
    24.    }
    25.    void StartWaterSampling()
    26.    {
    27.        waterSample.Start(Vector3.zero);
    28.    }
    29.    /// <summary>
    30.    /// Return water height y in world coordinates at world point x, z
    31.    /// </summary>
    32.    public float GetWaterHeightAtLocation(float x, float z)
    33.    {
    34.    
    35.        waterSample.GetAndResetFast(x, z, myWaterSystem.Time, ref currentWaterLevel, ref currentWaterForces);
    36.        waterHeight = currentWaterLevel.y;  
    37.        // Do not forget to uncheck "Flat Water" under Additional Options of FloatingObject.
    38.       //Debug.Log("Water : " + currentWaterLevel); // Will Slow down performance, to further speed this up make waterHeight Private
    39.        return waterHeight;
    40.    }
    41. }
    42.  
    43.  
    Note: Updated Code here, as I didn't want to leave a faulty version in this thread.

    Might be nice for UnityDynamicWater to support the Water Current Vector Data [currentWaterForces], to push the ship around.
     
    Last edited: Dec 13, 2017
    Lohrion and NWHCoding like this.
  32. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    686
    Great! Thank you very much for the post and great to hear that it was fixed (one way or another).
    I am rounding up all the scripts and will include them in the next version.
     
  33. DCrosby

    DCrosby

    Joined:
    Jan 13, 2013
    Posts:
    86
    Ok, you might want to fix the link on the store, because it takes you to the beta(this page) and not the release forum.

    I also suggest you have different "AddOn" packages that ship with Dynamic water, that support different water systems. I have updated the script in the main/release Forum area so use that one, this one complains after initialization that the "Water" object can't be found. So I built a bit of a delay into the other script, I'm abandoning this one as I assume things will move to the other page.

    Also you have my official stated permission to use that script in your product, it took me all of 10 minutes to put together, since I'd done it before with other physics packages, including trying to make my own, which failed miserably... took forever, and has 1/8'th of the features yours does.
     
  34. gsimons

    gsimons

    Joined:
    Oct 3, 2017
    Posts:
    5
    Does anyone know if this work well when you increase the timeScale value (Time.timeScale) to lets say 100x. Many other similar products I tried become unstable at this point, but for our ML purposes this speed-up is essential. If this would work we would definitely consider buying this product.
     
  35. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    686
    Hello,
    I have just tried it on the clean project and it does work. Since time scale is 100x this will also reduce performance. You might want to play with fixed delta time too if you are thinking of doing such high speedups.
     
  36. skaughtx0r

    skaughtx0r

    Joined:
    Mar 9, 2014
    Posts:
    35
    @NWHCoding I've been doing some optimizations in my code (trying to track down memory leaks) and noticed that Dynamic Water Physics was generating a lot of garbage each frame. It looks like most of it comes from generating new BuoyTri's and WaterLine's.

    I modified the code to instead initialize arrays of BuoyTri's and WaterLine's and just re-use them, I modified the classes to have an update function as well. Let me know if you want the changes that I made for any subsequent updates if this hasn't already been addressed.

    Oh, also I should mention that I am using Ultimate Water System (formerly Playway). You can get the water height queries to work in the Water Interface by not using the WaterSample class, instead just use
    Code (CSharp):
    1. water.GetUncompensatedHeightAt(x, z, Time.time);
    However, this is slower than the WaterSample class, so instead I opted for modifying FloatingObject to create an array of WaterSamples, so there's 1 sample for each dummyMeshVert. This seems to work fine.
     
    Last edited: Dec 26, 2017
  37. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    686
    It seems that you spent quite a some time on DWP.
    Seems good, did you take into account the fact that each triangle can be split up to three smaller triangles?
    If you want you can send the package and I will look into adding it into future updates, also since you spent so much time I can offer a refund.

    As for the PlayWay - thank you for the tip. I am pretty sure I tried it back when I was trying it out with PlayWay and it was very buggy. But that was some time ago and it could be that they fixed it since.

    Also, sorry for the (very) delayed response.
     
  38. skaughtx0r

    skaughtx0r

    Joined:
    Mar 9, 2014
    Posts:
    35
    Yes, its taking the triangle splitting into account, so there is some extra overhead, but the tradeoff is not allocating memory for every fixed update.

    No need for a refund, I can shoot you a PM with the changes I made sometime this week.
     
  39. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    686
    Sounds good. I actually implemented the same thing in my other asset Wheel Controller 3D a month or so ago and it did help, especially on mobile. DWP is getting an update soon with better ship controller since there is a lot of interest in that, I will put in you optimizations in then.
     
  40. DrabaL

    DrabaL

    Joined:
    Jan 4, 2018
    Posts:
    6
    Hi!

    Your simulator looks really close to what I want, just have some questions:

    How resource-intensive is the part that creates the dummy meshes?
    I'm making ships from up to 50K-ish low vertex(maybe 50 average) parts, they can be modified on the fly and destroying parts of the hull can open up pretty big internal compartments.
    Might need an entirely different approach but if this one is working for that case it's plenty to start.

    Do you have any way of handling "leaks"(in-game hull isn't breached, just water getting in)?
    If this asset can handle everything else plan B is simply adding some extra force/mass from the water inside, just checking :)

    Do you have something like UWS's "Volume masking"?
    Don't know if that's the common term, I mean the removal of water from submerged volumes.
     
    Last edited: Jan 6, 2018
  41. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    686
    Hello,
    Dummy mesh generation was never intended to be ran at real time. I am not aware of many solutions that can do that since it is not a simple process (take for example how long it takes to just create a convex collider when using mesh filter on high poly object). What I would do is simply assign the script to the every part. As indicated in the video it does not matter if you have 3 parts or 1 part in the shape of 3 parts - it will still work. Water-inside as you call it is not simulated so removing one of 50 parts would reduce buoyancy for the volume of that part but would not add any water weight.

    So my suggestion is to add floating object component to each of the objects you want to float, and then assign your parent's rigidbody as the target. Multi-editing is supported so this should be quite quick to set up.

    Good luck with your project.
     
  42. DrabaL

    DrabaL

    Joined:
    Jan 4, 2018
    Posts:
    6
    Yep, seemed a bit too simple to handle buoyancy :)
    Thanks for the quick reply, I'll look into it a bit deeper.
     
  43. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    686
    DWP does handle buoyancy, otherwise nothing would float in the demo scene. I am just saying that it does not simulate ingress of the water into the ship. That can be done easily (check the sinking video) by changing center of mass and rigidbody mass. And if you have a ship constructed of multiple parts of which every one is a floating object you will lose buoyancy that part represents. If you have seen the demo video there is a long-ish object created from 3 or 4 cubes - each one a floating object for itself. If you were to remove one the rest would still float but behave differently.
     
  44. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,563
    I'm trying to generate the dummy from my boat, but it keeps giving this error

     
  45. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    686
    Uh, seems like the mesh might be bugged. Could you sent me the model so I can check it out?
     
  46. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    686
    I am starting work on v1.1 as of today. Expect an update with better ship controller soon.
    There was quite an interest in the ship controller part - even if the included script is just a simple demo script - that I decided to make it into something actually useable outside of the demo.
     
  47. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    686
    Version 1.1 has been pushed to the store. Expect it to be live in a few days, after it gets approved.

    Changes
    - Added new ship controller that supports GUI Controls, multiple engines, bow and stern thrusters, engine sounds and more.
    - Greatly reduced garbage generation.
     
    Bartolomeus755 and Lohrion like this.
  48. 3dship

    3dship

    Joined:
    Jun 17, 2017
    Posts:
    7
    Great news, thank you for your effort and new update. :)
     
  49. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    686
    Update 1.1 is out.
    Also, demo on the website has been updated.
     
  50. vahag_im

    vahag_im

    Joined:
    Nov 10, 2017
    Posts:
    10
    Hello,

    Our project contains ~2K floating objects so performance is very important for us. We hope that new updates will solve our memory allocation issues (~202MB in fixed update). We've tried to update asset version, as as you've published asset with version 2017.1.1 we can't download asset (we're doing development with version 5.6.4). If you're not using any specific 2017.1.1 feature, please publish with lower Unity version. I'll also like to get package before republishing so I'll send the asset purchase invoice number with PM.

    Thank you.