Search Unity

Dynamic Water Physics 2 [Released]

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

  1. astanid

    astanid

    Joined:
    Apr 5, 2021
    Posts:
    145
    Just tried Dynamic Water Physics 2
    1. I've opened demoscene - i have no control. neither keyboard or mouse is working. what's up ?
    2. I like Crest URP asset - do you plan to add URP support for Dynamic Water Physics ? I tried - multiple errors, nothing is working :(
     
  2. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Hello,
    as for 1), have you managed to get it sorted with the help from Discord channel?
    Crest and Crest URP are the same as far as water height query is concerned. Make sure that you have followed the steps from the docs and added Crest to NWH.DWP2.asmdef by clicking on it, going to Assembly References section and clicking on +.
     
    Mark_01 likes this.
  3. Zarkow

    Zarkow

    Joined:
    Jul 27, 2015
    Posts:
    92
  4. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    There is no support for KWS Water System yet, except if you plan to use it as a flat water shader.
    I would suggest checking out Crest which is free and open source and might cover your use case.
    Quite a few people work on it and it is well optimized and supported and works out of the box with DWP2.
    There is also a known issue at the moment that the subs react to the waves even if underwater, so I have to point that out.
     
  5. Zarkow

    Zarkow

    Joined:
    Jul 27, 2015
    Posts:
    92
    Crest only seems to have versions for URP and HDRP in the store here - I am using builtin in 2020 for this prototype.

    If using KWS as a water shader only, it still sounds like I should wait with regards of using this to handle submerged vessles or perhaps write my own again?
     
  6. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Crest for built-in is free and available here: https://github.com/wave-harmonic/crest

    KWS will be fine if you are using it as flat water only. If you want to use waves there is no interface as of yet so the boat will just float as if the water was flat. Submerged vessels will work as intended with flat water.
     
    the_unity_saga and Zarkow like this.
  7. RoyorGames

    RoyorGames

    Joined:
    Mar 14, 2017
    Posts:
    25
    Hi,
    I have purchased the package and got it integrated to my other water asset and everything seems good on simple shapes.
    However, I am creating a modular boat (think a 5*5 raft), where each module can be destroyed and repaired. So I would like to turn off some modules, to simulate damage and less updrift. So the raft can sink, when to many modules are broken.
    I tried to create a gameobject with a rigidbody and a massFromChildren.
    upload_2021-7-16_21-0-37.png
    And then all children have:
    upload_2021-7-16_21-2-34.png

    My naive attempt of turning the gameObject on/off or the waterObject on/off did not do anything.
    Deleting the object completely is not quite what I want and it did not work as expected either.

    Taking the object and moving it way up in the air, works. So a work around would be to have a damaged object and show that when damaged and move the real one way up in the sky and turning it off. It seems error prone and would like to know if there is a better solution =)

    Best regards Povl
     
  8. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    The issues with destroying/deactivating WaterObjects sound like the ones fixed in the last update so I would suggest checking that you have v2.4.3.
    If the issue is just with the MassFromChildren script then a slight modification to that script might be required. Change the following line 22 inside MassFromChildren to:
    Code (CSharp):
    1. foreach (MassFromVolume mam in GetComponentsInChildren<MassFromVolume>(false))
     
    Mark_01 likes this.
  9. gamextar

    gamextar

    Joined:
    Jul 4, 2021
    Posts:
    9
    Hi, I'm having a similar issue, when destroying a water object at runtime with destroy function, other objects in the scene start to fly or sink or behave in crazy way. Is this a bug or is not possible to remove objects at runtime ? tried syncronize and makes no difference. I'm using the latest version
     
  10. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    I would make sure that you are using the latest version. In Unity 2021 there is a known bug where Unity shows the version as latest even when it is not. To make sure check the version field inside "NWH\Dynamic Water Physics 2\Resources\DWP2\Dynamic Water Physics 2 AssetInfo.asset", it should be v2.4.3.

    One reason why the objects might get upset is because Synchronize() can cause a CPU spike due to the native arrays that need to be re-allocated which could make physics jump a few steps and allow the objects to sink too much before starting to apply forces again once the Synchronize() has finished. That said, destroying or disabling WaterObjects will not call Synchronize (it is not needed, WaterObjects just get marked as disabled or destroyed) so in this case there should be no performance issues.
     
  11. gamextar

    gamextar

    Joined:
    Jul 4, 2021
    Posts:
    9
    I use unity 2021 and do have the latest version, the manual states that you should call synchronize to add objects at runtime which is true for me as if I don't call it, the objects just sink into the water. However I need to remove old objects after a while.. so I call destroy with a delay of 25 seconds. Thats when everything goes crazy. I don't know what the problem may be ? here's the part of code that instantiate the object and delete It after 25 seconds.


    if (useProjectile)
    {
    GameObject projectile = Instantiate(ProjectilePrefab, MuzzlePointTransform.position, MuzzlePointTransform.rotation) as GameObject;
    Rigidbody projectileRigid = projectile.GetComponentInChildren<Rigidbody>();

    projectileRigid.AddForce(MuzzlePointTransform.forward * ShotForce, ForceMode.VelocityChange);
    WaterObjectManager.Instance.Synchronize();

    Projectile proj = projectile.GetComponent<Projectile>();
    // Convert back to raycast if Time reverts
    if (proj && !AlwaysFireProjectile) {
    proj.MarkAsRaycastBullet();
    }

    // Make sure we clean up this projectile
    Destroy(projectile, 25);
    }
     
  12. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    This looks fine from what I can see. I will investigate to see what might be happening.
     
  13. UnityJopa

    UnityJopa

    Joined:
    Aug 10, 2021
    Posts:
    2
    Hello! How does your plugin work with WebGl?
     
  14. enghishamreda

    enghishamreda

    Joined:
    Jul 27, 2021
    Posts:
    1
    Hello,

    At some conditions In my game the floating object will be partially floating . When the object is partially float i need to get the center of buoyancy and magnitude of upward buoyancy force, how can I retrieve these data?
     
  15. RoyorGames

    RoyorGames

    Joined:
    Mar 14, 2017
    Posts:
    25
    Hi
    I am experiencing a few bugs, when destroying waterObjects.
    Do you have a proper way of doing this?
    E.g. should the synronize be called at some specific time or is there a different way to handle this?
    Best regards Povl
     
  16. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Hello,
    the forum decided not to notify me about new posts so sorry about late reply. The asset is purely physics oriented and uses pure Unity Rigidbodies so it works with any platform, including WebGL. The only thing that might have issues is the provided basic flat water shader from the demo scene, but any can be used instead.
     
  17. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Hello and sorry about the late reply. Forum sometimes fails to send me a notification - please consider joining Discord in the signature below.
    Buoyancy and all the other forces are calculated on per-triangle basis. You can access the data from the WaterObject or WaterObjectManager. It is a bit complicated but the easiest way to get this is to calculate the average force point using the Forces and Points arrays (first gives you the individual force applied at each Point). Summing the Forces array at indices where the States array is 0 (triangle is underwater) and 1 (triangle is partially submerged) will give you the resultant buoyant force. You can also check how the final force and torque are calculated in the WaterObject.cs file.
     
  18. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Make sure to update to the latest version as this was fixed there. You should be able to normally delete the object using Delete(). In the older versions there was a known bug that caused issues with this.
     
  19. RoyorGames

    RoyorGames

    Joined:
    Mar 14, 2017
    Posts:
    25
    Hi
    I just updated, but I cannot locate the Delete(). Which object class is it on? I have tried the WaterObject and the WaterObjectManager. Did you mean destroy(waterObject), the onDestroy does seem to mark the tris inactive.
    Also, I am using water in multiple scenes (different settings). Only one water scene is loaded at a time, so they are not interfeering with each other. When unloading a scene I get an error, that the water data provider cannot be found, even if disabling the waterObjectManager first. Do I need to disable anything else?

    And thank you for the quick response =)

    Best regards Povl
     
  20. RoyorGames

    RoyorGames

    Joined:
    Mar 14, 2017
    Posts:
    25
    Hi again,
    I just confirmed in a build, that the Destroy works as expected.
    Now the only error I have left, is when deleting the scene and having waterdataprovider not found a few times.

    BR Povl
     
  21. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Just destroy the GameObject as you would any normal GameObject. My bad, it was supposed to be Destroy(): https://docs.unity3d.com/ScriptReference/Object.Destroy.html

    The unload scene one might be a bug. I must admit I have not tested scene unload. It could be that your WaterDataProvider is referencing the water body that you are unloading and it leaves it with a null reference.
     
  22. RoyorGames

    RoyorGames

    Joined:
    Mar 14, 2017
    Posts:
    25
    Hmm.. my test was to limited. Adding more enemies (which die at different times), then destroying the object directly doesn't quite work as expected.
    I receive the following error:
    upload_2021-9-22_20-36-8.png
    and all waterphysics stops working.
    This is using the Destroy(gameObject) on a waterObject and then afterwards calling syncronize (in the same frame).

    If I manually call the syncronize, a few seconds after, then everything fixes itself. Is it possible that there should be a trigger syncronize in late update (or in the beginning of the next frame) after unity has deleted objects and such.

    The scene loading doesn't really hinder me right now, so take that in due time =)

    BR Povl
     
  23. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Could you check which version it is by checking the included AssetInfo file? There will be a field there with the current version. There were issues with Package Manager displaying the wrong version some time ago so just to make sure it is indeed the last one.
     
  24. RoyorGames

    RoyorGames

    Joined:
    Mar 14, 2017
    Posts:
    25
    It does say 2.4.3, same as the package manager.
    upload_2021-9-23_20-57-14.png
     
  25. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    I am working on the beta for v3.0 which will completely remove the need for the Synchronize() part and make everything much more simple on the end-user side.
    The error that you are getting should not be happening in 2.4.3 but it might be due to the execution order. I am not sure if Destroy() in Unity calls OnDestroy immediately or in some later phase - and OnDestory is what marks the data related to the destroyed WaterObject as invalid and makes the WaterObjectManager ignore it. You could try calling OnDestroy manually before actually destroying the object to see if it helps.
    Sorry for the issue. I did a lot of testing around this but sometimes always slips through :).
     
    the_unity_saga likes this.
  26. vertexx

    vertexx

    Joined:
    Mar 18, 2014
    Posts:
    379
    I hope you'll forgive me but most of my anims are to do with water/liquids and I'm always looking about for new assets.
    If I may post a link without trying to take things over video-wise... Hopefully just the link shows!!

    (EDIT. Now removed Youtube link as it doesn't really contribute to this product. My Youtube video can still be viewed. If interested..check my info for my Youtube channel site.)

    So far this is the best I can come up with for interaction water wise. Would your remarkable asset allow me to get a result similar or hopefully more realistic?
    PS. Can one post a link without the video automatically showing? I'm thinking it may look like click bait or whatever t5hey call it. And especially if one is comparing assets. But showing my attempts seems the best way for answers.
     
    Last edited: Sep 27, 2021
  27. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Hello,
    it would be quite more realistic since in your video it seems that you are simulating only buoyancy. In DWP2 that ball would bounce once and then be left bobbing on the surface, not act as if it was on a trampoline :).
    DWP2 also approximates hydrodynamics so the impact force is calculated depending on the shape of your object.
     
  28. vertexx

    vertexx

    Joined:
    Mar 18, 2014
    Posts:
    379
    Many thanks.
    I should have mentioned the splash. I am using a particle water splash and triggering it on collison.
    The Water asset used cannot simulate this by itself.
    If you look you will also see my attempt at the splash is very 2d.
    May I ask if your product can simulate this splash as part of it's function or does one need to add this manually?
     
  29. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Ah, I misunderstood the question then. The splash is not in DWP2, only the foam.
    Since the foam is a particle effect dependent on velocity and few other things, just locked to the 2D plane of the water, I guess it would be a good idea for me to look into implementing splashes too. If you decide to go the way of DWP2 I would suggest looking at the WaterParticleSystem (http://dynamicwaterphysics.com/doku.php/DWP2/WaterEffects/WaterParticleSystem) and modifying it to emit in 3 dimensions.
     
  30. RoyorGames

    RoyorGames

    Joined:
    Mar 14, 2017
    Posts:
    25
    A version without that need does sound like a good idea =)
    When is the 3.0 release estimated to be ready?
    and would this also fix the problem I am having when unloading a scene with WaterObjectManager and a WaterDataProvider?

    Who knows, maybe I am doing something strange. Right now my workaround is calling syncronize the following frame. Then it can't be seen =)
     
  31. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    The update will be releasing ~1 week. Most of the work has already been done, I just need to go over a few things. It will be shipped as an archive with the current version for beta testing. It is quite a large update (regarding WaterObject part of the asset, the ship part was left untouched) and while the editor and usage will stay mostly the same the backend for WaterObject has been completely rewritten in C++ for both performance in flexibility.
     
    Bartolomeus755 likes this.
  32. vertexx

    vertexx

    Joined:
    Mar 18, 2014
    Posts:
    379
    Indeed! I most certainly will.And many thanks for your interest.
     
  33. RoyorGames

    RoyorGames

    Joined:
    Mar 14, 2017
    Posts:
    25
    Looking forward to it :D
     
  34. the_unity_saga

    the_unity_saga

    Joined:
    Sep 17, 2016
    Posts:
    268
    hello dev, what unity version is the current DWP 2 developed in? I'm trying to make a small quick game centered around your asset but I am having difficulty trying to figure out most stable/or feature rich Unity version.

    do you have a recommendation for assets to use for DWP 2 out of the box?

    also, is it possible at all, to make a simplified version of your asset by adjusting certain parts of the source code, I was hoping to modify the physics model to cut down on iterations, or simplify it, how or where do I look to begin this? (slide show physics, or simplified rough calculations/no floats, etc)
     
  35. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Hello,
    Anything post 2019.4 will do equally well.
    The asset is already very well optimized and as such I would suggest leaving it as-is. The WaterObject part is separate from the ShipController and it is possible to use it by itself.
    As for the water assets - Crest is best supported and free for standard rendering pipeline. You can also use Crest as a flat water shader as flat water will have much lower overhead.
     
    the_unity_saga likes this.
  36. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    I am happy to announce one more feature coming with the update. The WaterDataProviders will now work based on physics triggers so that it is possible to have multiple water surfaces, even of different types, in the same scene. This means that an island in the middle of Crest ocean with AQUAS lake inside it will be possible. Other options such as multiple lakes, rivers, etc. will also now be doable.

    The update is expected in the next few days and will also feature a rewrite of WaterObject and removal of WaterObjectManager. This also means that objects will not need to be syncronized to work, which is something customers complained about in the past.
     
  37. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    I am happy to announce that NWH Vehicle Physics 2, Dynamic Water Physics 2, and NWH Aerodynamics will be 50% off from November 14, 2021, 21:00:00 PT to December 4, 2021, 23:59:59 PT.
    More info about the sale here.
     
    StarChick971 likes this.
  38. PeterSmithQUT

    PeterSmithQUT

    Joined:
    Sep 22, 2021
    Posts:
    9
    Just updated to the latest version and was looking through the code, I noticed that you implement `
    FastInvSqrt`. While definitely a really cool algorithm, I was reading that it's now superseded by hardware instructions on modern hardware:
    See:
    https://levelup.gitconnected.com/death-of-quake-3s-inverse-square-root-hack-32fd2eadd7b7
    https://www.linkedin.com/pulse/fast-inverse-square-root-still-armin-kassemi-langroodi
    If you had some performance metrics with and without I would be interested to see.
     
    Last edited: Nov 18, 2021
  39. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    I did a comparison profile before and after and it seems that it helped. I have not tested on mobile, however.
    In any case it is much faster than doing Vector3.Normalize() from what I tested and even if the new HW implementation is faster (up to 3.5x as they mention) it is not that many calls to really make a difference.
     
  40. homemacai

    homemacai

    Joined:
    Jul 22, 2020
    Posts:
    74
    Hello there ,installed DWP2 , everything works fine, but when enabling Burst, I did not find any file named WaterObject.asmdef to add the unity burst ref, but not throwing any errors. Should I be concerned?
     
  41. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Sorry, that is outdated documentation. Burst is no longer needed as the Jobs system was removed in v2.5 due to multiple downsides (namely having to re-allocate all the native arrays after adding a new WaterObject) and only marginal performance improvement.
    I will immediately remove this section from the online docs.
     
    homemacai likes this.
  42. StarChick971

    StarChick971

    Joined:
    Nov 28, 2015
    Posts:
    118
    Wait, Jobs system is no more available in Unity?? or only for DWP2? :eek:
     
  43. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    It was just removed from DWP2 due to the performance gain being ~10% while increasing the code complexity, making the asset harder to use and in general being bug-prone due to the way things were implemented. One of the reasons we can now have multiple water systems in the same scene is that the data for all the objects are not bundled inside one job, but rather processed on a per-WaterObject basis. Also, the memory footprint and usage went way down since there is less data duplication (accessing NativeArrays is slow so data has to be copied first to normal arrays before being accessed).
     
    StarChick971 likes this.
  44. homemacai

    homemacai

    Joined:
    Jul 22, 2020
    Posts:
    74
    Ah ok! Thanks! So I can remove the DWP_Burst from the Player/Scripiting Define Symbols right?
     
  45. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Yes.
     
    homemacai likes this.
  46. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
  47. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    An update is on the way. Clean import is recommended.

    ==== v2.5.6 ====
    == 05/04/2022 ==

    * Changed WaterDataProviders from file rename approach to Scripting Define Symbols approach.
    * Missing or incorrectly configured trigger collider on the WaterDataProvider will now get automatically added if missing, throwing just a warning instead of error.
    * Demo UI changes.
    * Improved the documentation regarding WaterDataProviders.
     
  48. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Another update is on the way, this time with multiplayer support.

    ==== 2.6.0 ====
    == 06/04/2022 ==
    * Added Mirror and PUN2 multiplayer support for AdvancedShipController.
    * Added StartOnThrottle option to Engine.

    upload_2022-4-6_22-20-9.png
     
  49. TaylorCaudle

    TaylorCaudle

    Joined:
    Feb 8, 2018
    Posts:
    158
    Any update on the KWS Water System integration? Would like to switch from Crest to this one, just wanna makes sure i can still use DWP2
     
  50. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    I already replied on Discord. In short - yes, expected for the next update.