Search Unity

Physics Dynamic Water Physics - Realistic. Fast. Universal.

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

?

Which water asset do you use with DWP?

  1. Crest

    112 vote(s)
    54.9%
  2. AQUAS

    15 vote(s)
    7.4%
  3. RAM

    17 vote(s)
    8.3%
  4. Ocean Community Next Gen

    6 vote(s)
    2.9%
  5. Ceto

    4 vote(s)
    2.0%
  6. SUIMONO

    7 vote(s)
    3.4%
  7. Ultimate Water System

    6 vote(s)
    2.9%
  8. Other Flat Water Asset

    8 vote(s)
    3.9%
  9. Other Water Asset With Waves

    29 vote(s)
    14.2%
  1. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Dynamic Water Physics 2 is out:
    Dynamic Water Physics will still be supported in the future and even available on the Asset Store, but it is recommended to switch to Dynamic Water Physics 2 as it is a complete rewrite with many improvements. Owners of DWP1 can upgrade for $10. Normally I do not charge for updates but DWP2 is essentially a new asset and it took a lot of time to develop it.
     
    Last edited: Dec 26, 2021
  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:
    2,260
    looks great and just what I need for my boat simulator. Purchased!
     
  4. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    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
     
    jbb1979 likes this.
  6. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    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:
    1,692
    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:
    1,692
    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:
    1,692
    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:
    101
    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:
    1,692
    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:
    101
    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:
    1,692
    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:
    101
    I'll collect a list of possible and probable future features if that's alright.
     
  19. Barritico

    Barritico

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

    Evgenius

    Joined:
    Sep 4, 2013
    Posts:
    21
    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:
    374
    Holidays??
     
  22. Barritico

    Barritico

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

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    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:
    374

    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:
    1,692
    I got alerted this time :)
     
  26. ZealousAppex

    ZealousAppex

    Joined:
    May 3, 2015
    Posts:
    17
    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:
    1,692
    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:
    1,692
    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:
    1,692
    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:
    1,692
    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:
    1,692
    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:
    74
    @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:
    1,692
    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:
    74
    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:
    1,692
    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:
    1,692
    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:
    1,692
    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,609
    I'm trying to generate the dummy from my boat, but it keeps giving this error

     
  45. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    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:
    1,692
    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:
    1,692
    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.
     
  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:
    1,692
    Update 1.1 is out.
    Also, demo on the website has been updated.
     
  50. Deleted User

    Deleted User

    Guest

    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.