Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

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

    101 vote(s)
    54.9%
  2. AQUAS

    15 vote(s)
    8.2%
  3. RAM

    15 vote(s)
    8.2%
  4. Ocean Community Next Gen

    5 vote(s)
    2.7%
  5. Ceto

    4 vote(s)
    2.2%
  6. SUIMONO

    6 vote(s)
    3.3%
  7. Ultimate Water System

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

    6 vote(s)
    3.3%
  9. Other Water Asset With Waves

    26 vote(s)
    14.1%
  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,626
    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,626
    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:
    346
    Hi @NWHCoding your store page link is not working on first page.
     
  8. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,626
    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,626
    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,626
    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:
    231
    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,626
    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:
    548
    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,626
    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,626
  17. bobadi

    bobadi

    Joined:
    Jan 3, 2019
    Posts:
    548
    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,626
    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.