Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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)
    55.2%
  2. AQUAS

    15 vote(s)
    7.4%
  3. RAM

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

    6 vote(s)
    3.0%
  5. Ceto

    4 vote(s)
    2.0%
  6. SUIMONO

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

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

    7 vote(s)
    3.4%
  9. Other Water Asset With Waves

    29 vote(s)
    14.3%
  1. UnityJopa

    UnityJopa

    Joined:
    Aug 10, 2021
    Posts:
    2
    Hello. How does it work with WebGL?
     
  2. WizardingStudios

    WizardingStudios

    Joined:
    Mar 4, 2017
    Posts:
    13
    Many thanks for the reply. I hope you should consider to add this simple shader to your assets... https://pasteboard.co/JVuiVRu.png (if possible with random or multiple waves)
    With a working boat I assure I will buy same day...
     
  3. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    Hello,
    since it is a physics asset and only relies on Rigidbodies for physics it will work on any Unity compatible platform. The only issue might be the water shader but the one included as demo is very basic anyways and the water shader does not affect the functionality of DWP2 so you can just use a plain opaque plane or nothing at all if you wanted.
     
  4. BlindMystics-P3TE

    BlindMystics-P3TE

    Joined:
    Feb 24, 2017
    Posts:
    3
    Hey, I think I've found a bug:
    ObjDynamicForcePowerCoeffs (Set per object) will be ignored if DynamicForcePower is 1.0 (Set in the Water Object Manager).
    The problem code is:
    Code (CSharp):
    1. if (DynamicForcePower < 0.9999f || DynamicForcePower > 1.0001f)
    2.                 {
    3.                     dynamicForce = -dot * Mathf.Pow(velocityMagnitude, DynamicForcePower * ObjDynamicForcePowerCoeffs[objIndex])
    4.                                         * densityArea * DynamicForceFactor * ObjDynamicForceCoeffs[objIndex] * normal;
    5.                 }
    6.                 else
    7.                 {
    8.                     dynamicForce = -dot * velocityMagnitude * densityArea * DynamicForceFactor * ObjDynamicForceCoeffs[objIndex] * normal;
    9.                 }
    A suggested fix would be:

    Code (CSharp):
    1. float dynamicForcePower = DynamicForcePower * ObjDynamicForcePowerCoeffs[objIndex];
    2.                 if (dynamicForcePower < 0.9999f || dynamicForcePower > 1.0001f)
    3.                 {
    4.                     dynamicForce = -dot * Mathf.Pow(velocityMagnitude, dynamicForcePower)
    5.                                         * densityArea * DynamicForceFactor * ObjDynamicForceCoeffs[objIndex] * normal;
    6.                 }
    7.                 else
    8.                 {
    9.                     dynamicForce = -dot * velocityMagnitude * densityArea * DynamicForceFactor * ObjDynamicForceCoeffs[objIndex] * normal;
    10.                 }
     
  5. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    Thank you for the spot. A new version with major changes is on the way where this was already fixed is on the way but will take at least a month to appear on the store due to the scope of the update.
     
  6. tgamorris76

    tgamorris76

    Joined:
    Apr 24, 2013
    Posts:
    292
    HI, i am trying to use DWP2 with crest but i keep getting these error messages

    Assets\NWH\Dynamic Water Physics 2\Scripts\WaterObject\WaterDataProvider\CrestWaterDataProvider.cs(4,7): error CS0246: The type or namespace name 'Crest' could not be found (are you missing a using directive or an assembly reference?)

    Assets\NWH\Dynamic Water Physics 2\Scripts\WaterObject\WaterDataProvider\CrestWaterDataProvider.cs(19,17): error CS0246: The type or namespace name 'OceanRenderer' could not be found (are you missing a using directive or an assembly reference?)

    Assets\NWH\Dynamic Water Physics 2\Scripts\WaterObject\WaterDataProvider\CrestWaterDataProvider.cs(20,17): error CS0246: The type or namespace name 'ICollProvider' could not be found (are you missing a using directive or an assembly reference?)

    Assets\NWH\Dynamic Water Physics 2\Scripts\WaterObject\WaterDataProvider\CrestWaterDataProvider.cs(21,17): error CS0246: The type or namespace name 'IFlowProvider' could not be found (are you missing a using directive or an assembly reference?)
     
  7. razzraziel

    razzraziel

    Joined:
    Sep 13, 2018
    Posts:
    395
    Hi @NWHCoding your store page link is not working on first page.
     
  8. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    Make sure to add the Crest assembly reference to DWP2 one (mentioned at the top here: http://dynamicwaterphysics.com/doku.php/WaterAssets). You can do this by clicking on the .asmdef file in the inspector and adding the value to the list there.
     
  9. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    Fixed. It was the old link for DWP1.
     
  10. SpindizzyGames

    SpindizzyGames

    Joined:
    Jun 29, 2017
    Posts:
    108
  11. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    If it is a fork it should be trivial to copy the Mirror implementation and just use that.
    There are many multiplayer assets and I can not cover them all but Mirror and PUN2 cover two most common approaches to this.
     
  12. andrew210

    andrew210

    Joined:
    Apr 23, 2014
    Posts:
    241
    Hello! Amazing asset, having some fun playing around with it so far. Im trying to play with some pretty extreme waves at the moment:



    I've not yet been able to find ways to configure it all so the boat is happier to stick better to the surface. At the moment the boat seems a little too happy to be drowned by waves and then fly back out above the water again. Any advice for values I could play with to change this behaviour so its happier to stay on the surface even in strong waves, would be amazing. Thank you for a great asset!
     
  13. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    The issue here is mainly the fact that DWP2 does not actually push the water out of the way. That means that it does not cut through a wave, but more of a pass through it. There can also be some discrepancy between the rendered waves and the CPU callback for the wave height. Playing with the settings on the WaterObject can improve this a bit (especially skin drag and slam/suction force coefficients), and possibly adding horizontal fins (e.g. using quads or cubes that have rendering disables) can also improve it.
     
    andrew210 likes this.
  14. bobadi

    bobadi

    Joined:
    Jan 3, 2019
    Posts:
    660
    hi, I wanted to check this out with LuxWater

    the wake foam seems to have a problem with ocean, it's above the ship. does it work with waves?
    on the bottom of the page: https://forum.unity.com/threads/released-lux-water.536631/page-37

    but my main issue is the input, I want to use a separate script to set values manually
    http://dynamicwaterphysics.com/doku.php/Input
    here says this should work
    Input now can be set from any script:
    myShipController.input.Horizontal = myFloatValue;



    my script looks like this
    Code (CSharp):
    1. namespace NWH.DWP2.ShipController
    2. {
    3.     public class boatCX : MonoBehaviour
    4.     {
    5.         public AdvancedShipController shipControl;
    6.         public float steer;
    7.         public float throttle;
    8.  
    9.         void Update()
    10.         {
    11.             shipControl.input.Horizontal = steer;
    12.             shipControl.input.Vertical = throttle;
    13.         }
    14.     }
    15. }
    but I get the error
    Assets\boatCX.cs(15,22): error CS1061: 'ShipInputHandler' does not contain a definition for 'Horizontal' and no accessible extension method 'Horizontal' accepting a first argument of type 'ShipInputHandler' could be found (are you missing a using directive or an assembly reference?)

    or if I use
    shipControl.input.states.Horizontal = steer;
    I get this
    Assets\boatCX.cs(15,29): error CS1061: 'ShipInputStates' does not contain a definition for 'Horizontal' and no accessible extension method 'Horizontal' accepting a first argument of type 'ShipInputStates' could be found (are you missing a using directive or an assembly reference?)

    also says
    AutoSettable should be set to false.
    isn't this the Auto Set Input?
    nwh.jpg


    what is throttle 2, 3, 4?
     
    Last edited: May 14, 2023
  15. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    Hello,
    the included WaterParticleSystem only casts particles as a 2D plane and so works with flat water. For 3D/wavy water the water shader has to implement foam since it is not possible to create a generic particle solution that would work with all the water shaders as this has to be integrated in the shader itself. E.g. Crest (free) has the foam generation.

    As for the input, thankfully this is an easy thing to solve. I have also updated the docs as the example was outdated. Thank you for pointing this out. The autoSettable was renamed to autoSetInput and horizontal to steering.
    This should work just fine:

    Code (CSharp):
    1.  
    2. shipController.input.autoSetInput = false;
    3. shipController.input.Throttle = 0.5f;
    4. shipController.input.Steering= -0.5f;
    5.  
     
    bobadi likes this.
  16. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
  17. bobadi

    bobadi

    Joined:
    Jan 3, 2019
    Posts:
    660
    since it was mentioned here:

    the wake foam is working with lux.
    on the material used by the particle system (WaterParticle.mat) the render queue must be changed directly to a higher number
    since the renderqueue value on the WaterParticleSystem doesn't seem to work
    nwh2.jpg

    also on the assetstore this forum is being linked, not the one above.
    cheers
     
  18. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    Thank you for pointing it out. I said that it did not work because the foam is 2D and does not follow the waves, but if the waves are very small it can be used.
     
  19. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    222
    something i forgot to ask, does this asset work in vr with quest 2/3 ?
     
  20. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    Yes it will. Just note that this is a forum thread for DWP1, but both will work with VR.
     
  21. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    NWH Vehicle Physics 2 and Dynamic Water Physics 2 are currently both 50% off as a part of the Unity Black Friday/Cyber Week sale!
    Check the links in the signature below.
     
  22. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    222
    yea thats why i asked the VR questions cause i was about to pull the trigger... and i just did woot woot! please dont drop support lmao

    next week: NWH 3!

    Me: Nooooo!!!! lol!

    so this should work with stylized water 1 and 2 correct?
     
  23. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    There are no planned "3" versions of any asset.
     
  24. el-UMT

    el-UMT

    Joined:
    Nov 9, 2023
    Posts:
    1
    But can you give an example how to integrate your boat controller script with XRWheel, XRLever, XR,Joystick and so on.
     
  25. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    There is no direct integration with any of the listed, but this can be achieved through scripting. This part of the docs should be helpful: Input [Dynamic Water Physics 2 Documentation]
    Not sure what kind of output XRWheel and the others give out but my assumption is some kind of float or Vector2 which then can be piped in directly into e.g.
    shipController.input.AutoSettable = false; shipController.input.Rudder = myXrWheelOutput;
     
  26. KarelA

    KarelA

    Joined:
    Dec 30, 2008
    Posts:
    422
    Hi. Does nwh support unity hdrp water asset?
     
  27. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    Hello,
    from the asset page:

    upload_2023-12-4_19-47-26.png

    Hope that helps.
    This means that you can use either any free flat water HDRP shader or e.g. Crest HDRP or similar.

    Regards,
    Aron