Search Unity

Dynamic Water Physics 2 [Released]

Discussion in 'Assets and Asset Store' started by NWHCoding, Jul 3, 2019.

  1. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    839
    That sounds like a good method with the lib folder. I'll have to look into that.
     
  2. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    839
    I don't fully understand the asmdef yet, but it seems that the problem comes from RAM scripts referencing AwesomeTechnologies Vegetation Studio Pro, which I am using, and shooting errors. from Ram spline and lake:
    Editor\LakePolygonEditor.cs(11,7): error CS0246: The type or namespace name 'AwesomeTechnologies' could not be found (are you missing a using directive or an assembly reference?)

    AwesomeTechnologies uses asmdef, should I add a asmref somewhere to connect these?
    Sorry for my ignorance in these asm functions.
     
  3. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Yes, just add the AwesomeTechnologies asmdef under RAM asmdef references and that should do it. I assumed that the error was in relation to DWP2, my bad.
    Also, this might help: Unity - Manual: Assembly definitions (unity3d.com)
     
    dsilverthorn likes this.
  4. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    839
    thanks!
    I'll give it a shot.
    I found a note on their Discord that said to remove the namespace from Project Settings, Player- I had to do it a few times, but it seems to work now. Now another asset is having the same reference errors to AwesomeTechnologies.

    Good point is that I have no errors from DWP2 now. Once I clear the other errors I can test again. Keeping my fingers crossed.
     
  5. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    839
    You called it! Thank you!!!
    I added the AwesomeTchnoligies.VegetationStudioPro.Runtime.as.def to the RAM.asmdef and it removed the errors.
    I guess it was because RAM did not use the asmdef before I added it for DWP2.
    Now I can finally test. :)
    Thanks again and I'll let you know how it turns out.
     
    NWHCoding likes this.
  6. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    839
    I have a boat working with DWP2 in my project.
    Next will be adding more boats and cars. I appreciate your help in getting this working. No problem with DWP2 and RAM working together now. Thank you!
     
  7. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Glad you got it working :)
     
  8. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Dynamic Water Physics 2 is getting a sail controller:

    upload_2023-4-30_20-25-49.png
     
    StarChick971 and dsilverthorn like this.
  9. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    v2.13

    03/05/2023
    • Cleaned up and commented out the sailing code. Added custom editors for all the sailing scripts.
    • Rework of the Submarine and Sink components. Both are now just VariableCenterOfMass MassAffectors, meaning they act as variable weight/ballast attached to the ship.
    • Transform position of the Sink component itself now determines the center of mass offset point / point of water ingress.
    • Submarine depth input now changes the relative depth instead of setting the absolute depth value. This means that negative input means deeper, positive input means shallower.
     
    dsilverthorn likes this.
  10. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    839
    I would like to enter the boat and then activate the boat, and to switch back to first person, have the player return to inside the boat, but it keeps putting me out into the water instead of inside the boat.
    For instance, drive out to a spot on a lake, change to first person and do some fishing, without jumping into the water.
    Can this be done and what setting do I need to change?
     
  11. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    This should be quite easy to achieve. Check the "Character-based ..." section here: Vehicle Changer [NWH Vehicle Physics 2 Documentation]

    But essentially the enter/exit point is fully adjustable. It seems that yours is off to the side of the boat or is not set up.
    Ignore the NVP2 title of the link, this code is shared between all the NWH assets.
     
    dsilverthorn likes this.
  12. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    839
    Thanks I'll go through it.
    I have the enter/exit point located right behind and above the steering wheel and reduced to .02, but I get kicked to the side. I will read through it and set it up again, I must have something incorrect in my settings.
     
  13. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    I can check if the point is working fine, although so far there have been no complaints about it. Since you mention that you get kicked, I would check if the immediate position after exiting is actually at the enter/exit point and you get kicked to the side because of a collision between your character and the boat. The enter/exit point does not check for any overlaps, etc.
     
    dsilverthorn likes this.
  14. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    839
    Good point. Thanks.
     
  15. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    839
    Quick question: is there a limit to the number of vehicles in the world? I am creating a very large open world with rivers and roads and want to have vehicles placed throughout.
     
  16. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    839
    Another question: I've noticed that my boats do not steer when the engine is not throttled up. Is there a way to steer while coasting?
    The situation is using a small outboard motorboat and trying to steer it to a dock while coasting and slowing down, but as soon as I throttle down I lose all control and the boat returns to going straight like there is not rudder.
    I want to bring in the sailboat as well and I know that sailboats are only controlled with rudder, so it should be possible (I would think) ;)
     
  17. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Of course it is possible. Check the demo ships and how they are set up. If you do not have any control when throttle is off most likely cause is that the rudder is missing a WaterObject. Rudder functions like any other WaterObject, and can be oversized if needed by using an invisible dummy mesh (again, check how it is done on e.g. Racer in the demo). That said, at near 0 velocity rudder can not steer a ship (except if not using propeller wash which here is not simulated, but I do not think that is your issue).
     
    dsilverthorn likes this.
  18. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    NWH Vehicle Physics 2 and Dynamic Water Physics 2 are currently both 50% off as a part of the Unity Spring Sale!
     
  19. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    839
    Perfect- I’ll check the rudder settings
     
  20. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    The rudder is just rotating a Transform, it does not check what is attached to it. You can also make your own rudder by just placing a scaled thin cube. In fact, that is the recommended way to do things like keels, stabilizers, etc. that might be missing from the model or are not adequately sized.
     
    dsilverthorn likes this.
  21. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    v2.14

    11/05/2023
    • Added SailPresets to SailController for better adjustability. These replace the previous lift and drag coefficients and the fixed force calculation.
    • Tab now toggles the demo UI.
     
  22. dsilverthorn

    dsilverthorn

    Joined:
    May 14, 2017
    Posts:
    839
    How do I control how long the boat will coast without power. I can't find it in the manual.
    The rudder is fixed thanks to your help, but the boat stops pretty quick and I would like it to coast longer after throttling down, if possible.
    Sorry for all the questions - I printed the manuals and have been testing settings, loving the results so far.
     
  23. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    The unfortunate downside of this approach to boat physics is that there is not a simple glider to do something like this, as the simulation is done on a triangle level. So reducing the slam and suction forces is pretty much the only way to go.
    That, or faking it by adding a bit of the forward force while the ship is moving.
    Since this is already a second question about this in a relatively short time, I will see what I can come up with.
     
  24. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    v2.16

    19/05/2023
    • Fixed intermittent NaN error caused by WaterObject.
    • Fixed SailController lift force direction, introduced in 2.15.
     
  25. BrightBit

    BrightBit

    Joined:
    Jan 22, 2013
    Posts:
    265
    I think I found a bug. I only used one WaterDataProvider instance in my scene that I positioned way above the ground but every time my boat exits the corresponding trigger area it keeps floating in the air at the same height.

    I currently fixed it myself with the following code in line 579 of the WaterObject.cs:

    Code (csharp):
    1.  
    2. public void OnExitWaterDataProvider(WaterDataProvider wdp)
    3. {
    4.     availableWaterDataProviders.Remove(wdp);
    5.  
    6.     // BEGIN FIX
    7.     CurrentWaterDataProvider = null;
    8.     for (var i = 0; i < vertexCount; ++i)
    9.     {
    10.         WaterHeights[i] = defaultWaterHeight;
    11.         WaterNormals[i] = defaultWaterNormal;
    12.         WaterFlows[i]   = defaultWaterFlow;
    13.     }
    14.     // END FIX
    15. }
    16.  
     
  26. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    v2.18

    29/05/2023
    • [VariableCenterOfMass] Fixed null issue when the GameObject is disabled.
    • [Vehicle] onActiveVehicleChanged now passes previous and current vehicles as params.
    • [WaterObject] Fixed the issue where when there are no WaterDataProviders active the WaterObject would remember the data from the last WaterDataProvider, instead of falling back to default.
    Thanks @BrightBit for reporting the last one, although I did change the solution to the issue up a little bit.
     
  27. bobadi

    bobadi

    Joined:
    Jan 3, 2019
    Posts:
    669
    hi, me again.

    I'm having a bit of a problem with water mask.
    what am I doing wrong, the renderqueues are correct, right?
    this is lux water. the ocean's rq number is 2999.
    nwhwatermask.jpg

    also did you use something else for water height calculation for lux water?
    the included utility seems like correct 60-70% of the time
    (like mentioned here, but my ocean is not scaled)
    Code (CSharp):
    1. public Material luxOcean;
    2. private LuxWaterUtils.GersterWavesDescription Description;
    3.     public float TimeOffset = 0.0f;
    4.     public Transform T;
    5.     public Vector3 pos;
    6.     public bool getHeight;
    7.     public Vector3 offset;
    8.  
    9.     void Start()
    10.     {
    11.         LuxWaterUtils.GetGersterWavesDescription(ref Description, luxOcean);
    12.     }
    13.     void Update()
    14.     {
    15.  
    16.     if (getHeight) {
    17.             pos = T.position;
    18.             offset = LuxWaterUtils.GetGestnerDisplacement (pos, Description, TimeOffset);
    19.         }
    20.  
    21. }
    luxwaterheight.gif

    a
    nd one more thing.
    this is where the hull / water object component should be for normal submersion
    hullheight1.jpg
    this is where it would be if aligned with deck. but then it's over water

    hullheight0.jpg
    tried fluid density and other variables but doesn't seem to help.
    so if there's no other way I guess this hull mesh collider should be set on a separate layer if I wouldn't want to collide it with other things if they are on the ship

    or can be more than one hulls / water objects be used for one ship?
     
    Last edited: May 30, 2023
  28. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Not sure why the rendering mask does not work there. Some water assets ship with their own water masks so I would check if Lux provides one. From the screenshots, everything seems fine.

    For the demo video, I used the LuxWaterDataProvider used with the assets. I am using the data provided by Lux, and I remember testing quite a lot with it to make sure that different ocean transform positions work fine. Still, I would suggest trying centring the Lux ocean transform to (0,0,0) and see if anything changes. Same for rotation. Not sure if there was something that changed with the updates of Lux so I will re-test.

    WaterObject does not use colliders at all, or care about them. The only thing it cares about is the MeshFilter component. So you can have an invisible mesh (MeshRenderer is not needed) that interacts with water. Check the demo boats, I have added stabilizers and a keel to the Racer and it is not visible nor does it have any colliders.
     
  29. bobadi

    bobadi

    Joined:
    Jan 3, 2019
    Posts:
    669
    thanks.

    luxWater seems to have one shader but it looks not for this
    LuxWater/Shaders/Resources/LuxWater_WaterMask.shader
    it is Hidden, and when creating new material, it is red.

    yeah, you're right, the water object doesn't need collider. nice.

    update: this depthmask works
    https://forum.unity.com/threads/released-lux-water.536631/page-38#post-9047437

    one change I did: lowered particles level so it looks better w wavey water
    in WaterParticleSystem.cs
    Code (CSharp):
    1.         [Tooltip("Elevation above water at which the particles will spawn. Used to avoid clipping.")]
    2.         [Range(-2f, 0.1f)] public float surfaceElevation = 0.016f;
    luxdwp.gif
     
    Last edited: May 31, 2023
    NWHCoding likes this.
  30. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Dynamic Water Physics 2 is on sale for two more days.
    Check the link in the signature below.
     
  31. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    The Dynamic Water Physics 2 sale is ending today.
     
  32. GarrettF

    GarrettF

    Joined:
    Jul 4, 2019
    Posts:
    49
    Hey quick question. I'm using Unity 2023. I understand it is experimental and have no expectancies for larger systems to work out of the box right away. But I wanted to ask about using Dynamic Water Physics 2 with the new Unity Water system.

    Will this still work with the new water system since its based on planes? Or is that something we don't know yet?

    Thanks in advance.
     
  33. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    HDRP water is not supported officially still because v16 had some API issues and thebdocs have not been updated to match the new API. However, there is an unofficial HDRP water v15 script in the Discord channel. Will be making the official update soon.
     
    GarrettF and Willbkool_FPCS like this.
  34. GarrettF

    GarrettF

    Joined:
    Jul 4, 2019
    Posts:
    49
    Hey I forgot to thank you for that. I was able to grab the script from discord and I now have my character using rowboats and pirate ships in Unity 2023 HDRP with Unity's new water system. It only took a couple of minutes!

    Thanks! Cant wait to start implementing sails.
     
  35. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Glad you got it working :)
     
  36. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    223
    It’s there a DWP3 coming? Or is this the one to buy?
    Also will this work on consoles, mobile and vr? Like quest 2/3? Which runs android?
     
  37. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    No, all the assets that have "2" in the name have been released as a major improvement / rewrite to the first version, both as I got more proficient at Unity over the years and to work as a part of NWH Physics World.
    The only possible release might be a DOTS version, but that will be in parallel since it is completely different technology.
     
  38. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    223

    Ok how about the other question? Will this work on mobile and consoles ?
     
  39. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Yes, it works on both. It is just using the standard Unity APIs so it will work on whatever Unity supports, and performance-wise, it is very well optimized and gives you the option to adjust the quality of the simulation mesh with one click. 20 ships will not be an issue on any platform.
    The biggest performance impact is usually the ocean/water asset that is used. Flat water is extremely fast both in CPU time and rendering, for example.
     
  40. QbAnYtO

    QbAnYtO

    Joined:
    Dec 18, 2016
    Posts:
    223

    Awesome. Thanks. it seems nothing else matches this asset. you got a banger with this one :)

    I was able to FAKE water driving with a boat but putting an invisible "ground" right under the surface of my water and it works really well. especially with plashes and all that. but i can't "ride" the waves or move with them.so i fake the "wobble" of the boat so it looks like its bobbing around the water. but if i make a big wave or something it won't ride with it. lol not bad for what in did but i prefer a more appropriate/native approach.
     
    NWHCoding likes this.
  41. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    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.
     
    StarChick971 likes this.
  42. kenlem1

    kenlem1

    Joined:
    Mar 20, 2014
    Posts:
    40
    The WaterObjectFromScript throws a null pointer exception.

    NullReferenceException: Object reference not set to an instance of an object
    NWH.DWP2.WaterObjects.WaterObject.Awake () (at Assets/NWH/Dynamic Water Physics 2/Scripts/WaterObject/WaterObject.cs:384)
    UnityEngine.GameObject:AddComponent()
    NWH.DWP2.DemoContent.WaterObjectFromScript:Start() (at Assets/NWH/Dynamic Water Physics 2/Scripts/WaterObject/WaterObjectFromScript.cs:13)

    Looks like it's trying to access the sim mesh before one is created. Am I doing something wrong?
     
  43. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Does the mesh you are using work when WaterObject is manually added, outside of play mode?
    Thank you for reporting it, I will look into it.
     
  44. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    I cannot send you the fixed script since your profile is set to not accept DMs, but the fix is to add:

    Code (CSharp):
    1.                    
    2. if (serializedSimulationMesh != null)
    3.                     {
    4.                         simulationMesh = serializedSimulationMesh.Deserialize();
    5.                     }
    6.  
    And then a few lines later:

    Code (CSharp):
    1.                 // Serialize only if mesh has been modified
    2.                 simulationMesh.name = "DWP_SIM_MESH";
    3.  
    4.                 if (serializedSimulationMesh == null)
    5.                 {
    6.                     serializedSimulationMesh = new SerializedMesh();
    7.                 }
    8.                 serializedSimulationMesh.Serialize(simulationMesh);
     
    Mark_01 likes this.
  45. kenlem1

    kenlem1

    Joined:
    Mar 20, 2014
    Posts:
    40
    I’m creating the mesh at runtime. Thanks for the fix.
     
  46. bobadi

    bobadi

    Joined:
    Jan 3, 2019
    Posts:
    669
    hi, one good thing is how dynamic water physics handles particles

    see particles stop when boat is above water
    dwpparticles.gif

    tried to do this with boat VFX
    (added dwp's WaterObject and WaterParticleSystem, but it seems is hooked up with the hull mesh, while boat vfx uses particle system's shape
    and also using new water object for every particle system seems like an overkill)

    could you support that?
    maybe the WaterParticleSystem could support more particle systems?

    and could you expose the water height in the WaterObject? (that would help much for spray vfx)
     
  47. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Hello,
    the mentioned included particles are intended for flat water only and usually the WaterParticleSystem would just be attached to the hull.
    The water heights are exposed through the WaterObject. There are a few result arrays including the depth of the traingle in question and the center of the triangle, and if you enable debugging/gizmos you will see lines drawn towards the surface of the water, indicating the height.
     
  48. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    The Unity Cyber Week Sale sale ends on December 6, 2023 at 7:59:59 PT, for those that might be interested in grabbing NWH Vehicle Physics 2 or Dynamic Water Physics 2 at 50% off.
     
  49. ThomasJacksonMAI

    ThomasJacksonMAI

    Joined:
    Oct 20, 2023
    Posts:
    5
    Hello, I am using DWP2 with crest in BIRP. I currently have a vessel with the submarine controller, this works fine until the vessel is completely submerged, as soon as the entire model is under the water it spins and sinks constantly, there is no depth it will stop at? Is this the desired behavior?
     
  50. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    The depth of sinking will depend on the mass of the object which the submarine controller sets, but the spinning could only be caused by the settings for levelling of the submersibles that are also under the submarine controller.