Search Unity

Assets Dynamic Water Physics - Realistic. Fast. Universal.

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

?

Which water asset do you use with DWP?

  1. Crest

    12 vote(s)
    35.3%
  2. AQUAS

    7 vote(s)
    20.6%
  3. RAM

    3 vote(s)
    8.8%
  4. Ocean Community Next Gen

    3 vote(s)
    8.8%
  5. Ceto

    1 vote(s)
    2.9%
  6. SUIMONO

    2 vote(s)
    5.9%
  7. Ultimate Water System

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

    0 vote(s)
    0.0%
  9. Other Water Asset With Waves

    5 vote(s)
    14.7%
  1. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    Hello,
    SInce the system uses it's own simplified mesh you can do whatever you want with colliders. You could have 1, 10 or 20 colliders as a part of the ship. The only thing that is required is to have at least one since rigidbodies require that.
    So you can have separate collider for hull, cabin, small parts, etc. One suggestion is to create colliders in modelling software as it is easier that way, but you could make everything out of primitive colliders as far as DWP is concerned.
     
  2. freshmeat911

    freshmeat911

    Joined:
    Nov 3, 2016
    Posts:
    73
    I'm really watching this asset, and waiting to see what happens for submarines, if anything. if I'm happy with the result for subs you'll have another sale. keep up the good work man looks great!
     
  3. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    Submarine would work fine as it is, but the included Ship Controller is just what it says on the lid and would not work with most submarine functions such as submerging and elevation control. Just need to find a decent submarine model (or make one) and will include one - shouldn't be more than a two or three hours of work on my side.
     
  4. freshmeat911

    freshmeat911

    Joined:
    Nov 3, 2016
    Posts:
    73
    Amazing, I already made a model but my coding skills are non existent lol thank you for the response. I will await the update ;)
     
  5. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    No problem. I will draft up a submarine model in Blender and rig that. But essentially it is not much more than changing the mass of submarine's rigidbody (and in some cases center of mass) until it starts sinking and then adding additional rudders for verical control. DWP itself works as fine under water as it works above water.
     
  6. GamePyro

    GamePyro

    Joined:
    Jul 28, 2018
    Posts:
    154

    Want buy it but:

    At store stand 2017.4.6


    Have you a version for 2017.1.1f also ? or work it with that ?

    And is all included the boats etc and the water effects from boats etc ?

    Thanks


    Regards
     
  7. Parallel_

    Parallel_

    Joined:
    Dec 9, 2012
    Posts:
    90
    Will it work out of the box with deformed meshes like with megafier modifiers or blendshape meshes?
     
  8. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    Hello,
    I have to mention that Dynamic Water PHYSICS is a physics package made to work with multiple ocean assets. Ocean Community Next Gen is one of them and it is free. I have no affiliation with it and used it in demos just because it is open source and available to all.

    Now for your problems:
    - Ocean Community Next Gen does not work in Editor view - only in game mode.
    - For this you will have to mess around with settings.
    - Crash - it could be that the shader causes crash on newer Unity versions. Again - Ocean Community is not my asset and I do not offer support for it.

    I would suggest trying Crest Ocean which is new and open source solution and should work with DWP. I will be adding official support for it soon as it is on of the best water systems at the moment and free too.
     
    3dship likes this.
  9. GorkaChampion

    GorkaChampion

    Joined:
    Feb 6, 2018
    Posts:
    102
    Hi, Any ideas how can I sink the boat from script? (For instance in a ship battle)
    Ideally with a nice (realistic) behavior while sinking....

    Thanks!
     
  10. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    This is quite simple but can be made to be somewhat complex - depends on what you are looking for.
    First lets look at what happens when a ship is sinking. Ship is usually made out of materials denser than water (1200 - 7000 kg/m3) and air that fills in the voids (ignore the mass). So the total volume of the hull that is under the water line is actually lighter than water and in my experience about 400-500 kg/m3. When water gets into the hull through a hole in it density starts increasing and the ship will sink when density reaches value above the density of water (salt water ~ 1030 kg/m3).
    So what you need to do for simple sinking is just increase the mass of rigidbody in question. Check this link for a simple example that I made: http://nwhcoding.com/index.php/2017/08/30/sinking-a-ship-in-dynamic-water-physics-for-unity/

    If you want to keep it more realistic you would also change the center of mass as the water enters the hull, possibly towards the hole. Most modern ships have ribs in their hulls that prevent water getting to other parts of the ship if one section takes on water. So you could move the center of mass through the provided script towards the section that is gaining water.

    Just some ideas - this could be made as simple or as complicated as you want but for most people the second option will be enough.
     
  11. GorkaChampion

    GorkaChampion

    Joined:
    Feb 6, 2018
    Posts:
    102
    Thanks!
    I made a coroutine function calling with different mass and time for 5 times (From 0 sec to 30 sec) but this script may help me to: 1. do it more progressive 2. add the center of mass movement.

    By the way, I saw Crest yesterday because your post and it looks amazing. Did you test it? I'm using Aquas right now but I'm missing the waves part....
     
  12. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    825
    Hi, which post is that? I thought crest is not worked on anymore..
    Oh wait, I see it now :) Ignore me
     
  13. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    Expect a new update in a few days time.
    Expected changes:
    - Added a submarine.
    - Added support for Crest.
    - Minor improvements and fixes.
     
    3dship and Bartolomeus755 like this.
  14. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    For anyone that wants to try it out I have attached a water interface script for Crest.
    Just note that Crest requires Unity 2018.2 to work.
     

    Attached Files:

    3dship likes this.
  15. GorkaChampion

    GorkaChampion

    Joined:
    Feb 6, 2018
    Posts:
    102
  16. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    It works fine with 2018.3 as the only thing from PhysX that is used in scripting is AddForceAtPosition(), and once per object at that. I have not tried 2019.x versions but I assume they work fine too.

    I am happy that they are updating PhysX since it had many problems a few years ago (2.x) and nowdays it is quite stable without need for many fixes. Especially the collision detection at high speed.
     
  17. GorkaChampion

    GorkaChampion

    Joined:
    Feb 6, 2018
    Posts:
    102
    ok, that's good news, did you test if there is a better performance in your asset? (It's one of the points of 3.4 as they say...)
     
  18. mohitsabhi

    mohitsabhi

    Joined:
    Feb 11, 2017
    Posts:
    5
    Hi !!

    Stuck with an issue with the Particle system for the Boats Wash / Wake on network client, could you please help for the same. As per below screen shots, on the host PC all works well but on the Client the Particle effects don’t render correctly.

    Appreciate your advice/assistance.
     

    Attached Files:

  19. mohitsabhi

    mohitsabhi

    Joined:
    Feb 11, 2017
    Posts:
    5
    Solved Mine above !!

    Thanks to the FAQs in the User Manual, which i missed :)

    WATERFX PARTICLES APPEAR AS WHITE TRIANGLES IN BUILD.
    Add „WaterParticleShader“ to the Always Included Shaders under „Edit>ProjectSettings>Graphics“.
     
    NWHCoding likes this.
  20. Mohamed-Anis

    Mohamed-Anis

    Joined:
    Jun 14, 2013
    Posts:
    81
  21. MeadowGames

    MeadowGames

    Joined:
    Dec 15, 2013
    Posts:
    4
    Hi, I'm thinking about buying Dynamic Water Physics for my mobile game and since a video tutorial is not available an apk file demo would be unbelievable helpful. My phone only has 1.5 GB of ram and a GPU slow as molasses so I will need to configure your asset on the lowest settings possible in order to get a decent frame rate. In your first post you mentioned a built in mesh decimator which would help reduce poly count but I need to see real world example.
     
  22. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    It really depends on what kind of data you can provide. WaterInterface samples water height at many points, not just one, so saving something akin to queryable mesh is required. Most ocean sistems have this (in fact, in have not yet come across one that does not as it is required to generate waves) but I do not know about the river systems. Most of the river systems I saw so far are materials and do not calculate actual water positions and what not.

    As for water currents, they can be added using AddForceAtPosition() since all the floating objects are pure rigidbodies and can be influenced like one. So if you have laminar flow you can just use single vector or if you have turbulent water flow you can use some kind of vector map. If you get to implementing this contact me and I will provide you with some details and tips.
     
    Mohamed-Anis likes this.
  23. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    Thanks for the feedback. The thing is that the demo scene has some quite high poly models and the ocean used for demo is not really something that would run on low spec mobile phone (Ocean Community Next Gen) since it is procedurally generated. For mobile use I would recommed something like AQUAS with low poly ship models.
     
  24. 3dship

    3dship

    Joined:
    Jun 17, 2017
    Posts:
    7
    Hello,

    I am getting these errors when i add to waterinterface for crest;
    can we solve ? thnx

    Assets/DynamicWaterPhysics/Scripts/WaterInterface/WaterInterface.cs(23,50): error CS1502: The best overloaded method match for `Crest.ICollProvider.SampleHeight(ref UnityEngine.Vector3, out float, float)' has some invalid arguments

    Assets/DynamicWaterPhysics/Scripts/WaterInterface/WaterInterface.cs(23,81): error CS1620: Argument `#2' is missing `out' modifier
     
  25. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    Looking at the git for crest-oceanrenderer it seems that there has been an update to version 4.0 17 days ago. The version of the water interface was tested with 3.0. They changed the function from

    SampleHeight(ref position, ref height);


    to

    SampleHeight(ref position, out height);


    So just change that and you should be good to go.
     
    3dship likes this.
  26. Mohamed-Anis

    Mohamed-Anis

    Joined:
    Jun 14, 2013
    Posts:
    81
    @NWHCoding does this work with skinned meshes? Or just physics joints? In particular do we need to manually create the physics joints and the colliders/rigid bodies between them or will it be automatically generated?
     
    Last edited: Nov 28, 2018
  27. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    There are no joints of any kind. DWP approximates forces from the decimated dummy mesh that it auto-generates from the original mesh. Therefore, floating objects are pure rigidbodies with one force applied per frame which is calculated from the different areas, angles, volumes, etc. and triangle position and velocity. Skinned mesh is not supported out of the box - at one point in development it was actually supported but to access vertices and triangles of a skinned mesh you have to bake it first which is quite expensive and therefore the support for it was dropped. BUT what you can do quite easily and what I would recommend is adding primitive shapes to your characters parts (assuming it is a character) and setting those individual parts as floating objects. Think of DWP as a "mesh collider that interacts with water" and things will be clearer.
     
    Mohamed-Anis likes this.
  28. Mohamed-Anis

    Mohamed-Anis

    Joined:
    Jun 14, 2013
    Posts:
    81
    @NWHCoding I just purchased it due to your honest and quick replies. Fingers crossed I'll find some good use for it (I do have a use in mind.. so we'll see how it goes) :).
     
  29. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    181
    Hi.

    I need to simulate the physics of a vehicle (car, truck) when it falls into a swamp. The necessary effect would be to float for a while to sink progressively.

    The physics that I have nowadays are not useful to achieve it.

    I am a customer of your vehicle physics and I was wondering if with this asset I could achieve this effect.

    Thank you.
     
  30. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    Hello,
    the answer is yes you would, and quite easily.
    Set it up as a normal floating object (which takes whole 10 seconds once you know what to do, for the first time I would recommend step by step guide in the manual). Sinking is quite easy to achieve and usually increasing the mass of the rigidbody is the best and easiest way to do it - this is in essence what happens when a vehicle fills up with water which displaces the air inside it anyways.
    Have fun :)
     
    Barritico likes this.
  31. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    469
    Hi, NWH,

    I own both the DWP and VP and trying to have both of them in a single game.

    I'm trying to merge Change.cs and VehicleChanger into one class and add support to ship into CharacterVehicleChanger.cs
    And it makes the coding little bit unclean since AdvancedShipController and VehicleController does not share the same parent Class. I have to make the same function twice for each classes.

    Is it possible for them to share the same parent class, perhaps by creating an abstract class, VehicleBaseController?

    It will then make the code much cleaner.

    Thanks and wish you the very best.
     
  32. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    I see no problems with that. Make a base class A, make it inherit from MonoBehavior and then make it a base class for both the cars and the ships which both inherit directly from MonoBehavior as is.
     
  33. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    469
    I know I can do it myself, but if I do, I'll have to do this everytime I get updates.
    Will you please do this in your code in the next update?

    Thanks.
     
  34. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    Since they do not ship together I can not. If they did, I already would have. But really, if you make the change the only thing you would need to change when updating is switch MonoBehavior to your custom class in two files.
     
  35. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    469
    Sure, I'll do it for the time being.
    I think it's a good idea refactor them to share the same code. There are more than just having a common class, Engine, Speed, and InputHanders can be refactored to the common class plus some more.

    Besides, the current code doesn't use namespaces and it uses a common class name such as Engine conflicting some other Asset (which also uses global class name Engine)

    Anyway, I hope you find a chance to factor them when you look at it next time.

    Cheers!
     
  36. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    A small update (1.3.1) is coming with a fix to ships not responding to any input if bow and stern thruster axes are not set up in input manager. Expect it as soon as it gets approved.
     
    3dship likes this.
  37. Bartolomeus755

    Bartolomeus755

    Joined:
    Jun 20, 2013
    Posts:
    240
    I tried DWP with the newest version of Crest and the SampleHeight error still exist. Any chance to get an updated WaterInterface script to get DWP working with Crest?
     
  38. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    Here you go.
    I have fixed this (there was an API change on their side) but am still waiting for them to fix the ocean breaking when height is queried >250 units from origin. This has possibly been fixed it but I have yet to test it:
    https://github.com/huwb/crest-oceanrender/issues/179

    Also, I will be releasing an update with much improved ship behavior in wavy waters. So far floating objects have relied on Unity's drag which works fine when the object is submerged for the same percentage most of the time, but results in bouncy behavior on wavy surfaces.
    In short, there will be a drag field and drag will be calculated together with other forces. It has already been implemented for a game I am working on but I need to do code cleanup first.
     

    Attached Files:

    derkoi, Efril, 3dship and 1 other person like this.
  39. Bartolomeus755

    Bartolomeus755

    Joined:
    Jun 20, 2013
    Posts:
    240
    Thank you very much for the updated script, looking forward to the new version of DWP.
     
  40. obstudio

    obstudio

    Joined:
    Sep 30, 2016
    Posts:
    52
    Hi, are you planning to make inteface for ship controller? For now there are no methods for engine start/stop and Activation of ship.
     
    3dship likes this.
  41. GorkaChampion

    GorkaChampion

    Joined:
    Feb 6, 2018
    Posts:
    102
    I have just bought Lux Water and is awesome.
    Any plan to integrate with it, as it's got very nice waves formations. Would be awesome to use the render wave high to make the buoyancy effect (as you did with crest)
     
  42. HonKasumi

    HonKasumi

    Joined:
    Apr 25, 2018
    Posts:
    23
    hello there, how to fix this 'issue Input Axis BowThruster is not setup'??
     
  43. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    Hello. It is exactly what it says - you need to go to Edit > Project Settings > Input and add "BowThruster" and "SternThruster" as inputs there. That is it. Too add inputs just increase the number of axes.
     
  44. GorkaChampion

    GorkaChampion

    Joined:
    Feb 6, 2018
    Posts:
    102
    Ok, I'll do the integration as I know where to get the wave high, but I need some tips how to do it on your code, where do I adjust the offset? Thanks
     
  45. HonKasumi

    HonKasumi

    Joined:
    Apr 25, 2018
    Posts:
    23
    ohh thanks for that, im new to unity xD i also did my own ship with the bouncing, and it looks well, it bounce nive to water, but i have 3 issues with it.
    First is that when i drag the ship underwater and than let goo the ship just goes really high in the sky and it takes a while till it stabilizes, and second is when my ship is upside down the ship just goes really fast downside underwater till i cant see it anymore, but it dosent happen will my other ship and the third is that i cant change the rotation of Z axis, when i try itchanges the Y axis
     
    Last edited: Mar 10, 2019
  46. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    I am not sure that with Lux you can get the wave height as the waves seem to be faked inside the shader. I will contact the author about this.

    Send me an email and I will send you the code for improved calculations, including drag, which should solve the problem with flying high as you say it.

    The second problem seems like it is much denser than the water and it sinks, or at least it seems so from your description. Try reducing the mass on it and make sure the scale is 1,1,1 on the rigidbody.
    I am not sure what Z and Y axis we are talking about? Transform rotation?
     
  47. GorkaChampion

    GorkaChampion

    Joined:
    Feb 6, 2018
    Posts:
    102
     
  48. HonKasumi

    HonKasumi

    Joined:
    Apr 25, 2018
    Posts:
    23
    The 2 issues are just setting that i figure it out now, and yes when i try to change the z axis its thr same as i change the y axis, maybe it has something to do with the mass not sure, but i have to say your asset is really Awesome and easy 10/10
    Here what i have done



    Can you maybe make like a check box for those who want to use in your setting that says when the ship is too deep underwater it just sinks and doesn't get up again, it would be more realistic
     
  49. freshmeat911

    freshmeat911

    Joined:
    Nov 3, 2016
    Posts:
    73
     
  50. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    Hello,
    this can easily be handled by just increasing the mass of the rigidbody. Something like this:

    Code (CSharp):
    1. if(myShip.position.y < someHeight)
    2. {
    3.      // Approximate water ingress
    4.      myShipRigidbody.mass += someValue * Time.fixedDeltaTime;
    5. }
    Where someValue is liters/second of water entering the ship.