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. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    No problem. Since Unity takes a few days to review anything I will send it directly to the address you provided instead. Expect it in a few hours.
     
  2. Deleted User

    Deleted User

    Guest

    Thank you for quick response.
     
  3. 3dship

    3dship

    Joined:
    Jun 17, 2017
    Posts:
    7
    Hello, I have a small problem Fx Water with Ceto Ocean, I added WaterParticle in "Always Included Shaders“ field. waves looks like in the screenshot, I couldn't fix it,



     
  4. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    Hello,
    I am not exactly sure on how Ceto works but it seems to me that it might be the problem with shader render queue (same as with AQUAS). What happens is that the foam gets rendered first and then the water which makes foam appear under water. So to fix this you will need to either increase render queue of foam to be larger than Ceto's or reduce Ceto's to be lower than foam's render queue. Either will work.
    This is the most likely reason, it could also be something like Ceto placing waves above it's Y position which would result in water being over the foam "physically". You can test this if you pause the scene in play mode and drag one of the foam objects upwards. If it is a render queue problem it will still look as if under water and if it is the second problem it will appear just fine.

    Hope this helps.
     
  5. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,976
    Here is a version of "WaterInterface.cs" for Suimono:
    Code (CSharp):
    1. using UnityEngine;
    2. using Suimono.Core;
    3.  
    4. /// <summary>
    5. /// Version for Suimono
    6. /// </summary>
    7. public class WaterInterface : MonoBehaviour {
    8.  
    9.     public SuimonoModule Suimono;
    10.  
    11.     /// <summary>
    12.     /// Return water height y in world coordinates at world point x, z
    13.     /// </summary>
    14.     public float GetWaterHeightAtLocation(float x, float z)
    15.     {
    16.         return Suimono.SuimonoGetHeight(new Vector3(x, 0, z), "height"); ;
    17.     }
    18. }
    But there is a problem - the engine seems to have no effect. I can't accelerate the boat on a Suimono ocean... :(
    What could be the issue?
     
  6. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    Hello,
    the most probable culprit would be the part of the code that checks if the propeller is under water. Just put:
    submerged = true;
    at line 170 in Engine.cs and see if it fixes the problem.

    Thank you for posting the water intefrace.
     
  7. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,976
    Thank you for your fast response!

    I changed "submerged" to true and it works!
    It would be nice if you could add an Editor flag like "AlwaysSubmerged" for cases like this.
     
  8. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    There is no such option since this is not supposed to happen. In other words - it is a bug.
    I will see what might be causing it and change it in the next update.
     
    Stefan-Laubenberger likes this.
  9. Stefan-Laubenberger

    Stefan-Laubenberger

    Joined:
    May 25, 2014
    Posts:
    1,976
    Thank you for your effort!

    P.S: I wrote you a PM ;)
     
  10. Efril

    Efril

    Joined:
    Aug 31, 2013
    Posts:
    82
    Hello @NWHCoding. Using this asset is any way to find a moment when ship buoyancy becomes negative and it starts to sink? I see no events there but maybe it is possible to calculate it somehow.
     
  11. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    There are no events but it is quite easy to get from volume and mass, as soon as density goes over the density of the water. Basically the inverse of the included script MassFromDensity. I will provide the code tomorrow as I am out of office at the moment and typing from mobile.
     
  12. Efril

    Efril

    Joined:
    Aug 31, 2013
    Posts:
    82
    Thank you for quick response. And what if ship have few FloatingObjects with different values of 'Fluid density' parameter (for better alignment)?
     
  13. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    Calculating the simple weighted average in that case will do just fine, e.g. (just a pseudo code):

    volumeSum = 0;
    iterateOverObjects { volumeSum += objectVolume }

    totalDensity = 0;
    for(objectID in objects)
    totalDensity += density[objectID] * (volume[objectID] / volumeSum);
     
  14. enlite

    enlite

    Joined:
    Feb 27, 2017
    Posts:
    19
    Hi,
    I have just bought the asset but can't seem to get my boat to move in the sample scenes? am I missing something?
     
  15. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
  16. enlite

    enlite

    Joined:
    Feb 27, 2017
    Posts:
    19
    Thank you for responding, I have fixed the problem by moving the input.Update() from the FixedUpdate() to Update().

    Code (CSharp):
    1.   void Update()
    2.     {
    3.          input.Update();
    4.     }
     
  17. enlite

    enlite

    Joined:
    Feb 27, 2017
    Posts:
    19
    Hi,
    How would you best apply DWP to a catamaran type boat?

    Should I use 2 hulls with 2 floating objects, or is it best to use one simplified hull?

    Thanks in advance.
     
  18. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    Both are valid options. One hull will work just fine, just do not check convex when simplifying mesh if you are using a single floating object.
     
  19. enlite

    enlite

    Joined:
    Feb 27, 2017
    Posts:
    19
    Thank you. I will give it a go.
     
  20. melonhead

    melonhead

    Joined:
    Jun 3, 2014
    Posts:
    630
    Does anyone have a waterinterface.cs script for AQUAS water?
     
  21. DCrosby

    DCrosby

    Joined:
    Jan 13, 2013
    Posts:
    86
    If I remember Aquas is Flat. so if you tag the surface with "Water" it should work... no interface needed, only non flat water surfaces, need an interface to sample height.
     
  22. DCrosby

    DCrosby

    Joined:
    Jan 13, 2013
    Posts:
    86
    I have a request that I made prior, during my UWS Interface post, but now I'm working on something different, and need it now more than I did back then.

    I'm now working on a river system, and boyancy is only 1/2 of it, river flow direction, either via a spline, or being able to sample a surface, no matter how it's done I can handle getting or setting the data, DWP should have the possibility to add directional water flow into its buoyancy calculation. Can you add a function to add a vector to Floating Object ? Also my Engine stuff also doesn't work in UWS, as somehow it can't figure out if the screw is in the water or not.
     
  23. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    The thing for detecting if the propeller is out of the water is a known bug and can be fixed by deleting the code after line 155 to line 161 in Engine.cs and replacing it with submerged = true.

    Heh, the other thing you are requesting is actually in there but you are overthinking it. Since DWP uses plain rigidbodies you can do something as simple as:

    floatingObject.rb.AddForceAtPosition(force, position);

    This is what DWP does to make objects float and adding additional forces can be done in the same way.
     
  24. DCrosby

    DCrosby

    Joined:
    Jan 13, 2013
    Posts:
    86
    Yes, I ended up doing that in a separate script to not mess with yours, as I don't want to have merge issues if I update. I would just think that this is a "Common Feature" and should be added as a parameter in the buoyancy script and the water interface so that people who want it can use it.
     
  25. DCrosby

    DCrosby

    Joined:
    Jan 13, 2013
    Posts:
    86
    So as I inch to my goal of having a river based game, with waterfalls, and such I'm running into several issues, the river systems that have collision information, basically expose it as a MeshCollider, which is not Convex, and if it's not convex, which 99.9% of rivers, I'd imagine are not, then I start colliding with my ship once I hit the surface, if I disable collision between two objects, I lose the ability to fire rays against it to measure height for Water Interface. Maybe I can get world position information from the spline, I will try that next, although that would prevent things like rivers banking during fast speeds around a turn in a canyon. For reference I'm using Curvy to prototype the river geo, as Cascade, and R.A.M. have no provision for height information. Thoughts ?
     
  26. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,476
    Hi, I'm curious about the game you are making, is it kayaking or so?
     
  27. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    I must admit that I have no experience with river systems but making a fast script to query mesh positions could be the way to go. This is quite easy to do if the mesh we are talking about is regular (i.e. checkerboard) but can become expensive and complicated for more complex meshes.

    Definitely the easiest way would be to raycast against the surface - possibly using this to prevent collision while still being able to query: https://docs.unity3d.com/Manual/LayerBasedCollision.html
     
  28. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    Just a quick notification that v1.2 is in the making and will support major water systems out of the box with water interfaces included and will fix the problem with propulsion thinking that it is out of the water. Expect it during the next week.

    Edit: the submarine part was moved to the next update.
     
    Last edited: Jul 7, 2018
    3dship and nefirma like this.
  29. Deleted User

    Deleted User

    Guest

    Hello,

    I would like to know if there any plans to switch to new ECS design? According to Unity's any other developers feedback it significantly reduces runtime costs.

    Thank you.
     
  30. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    Yes, but only after they get a few versions out and make it stable enough. There will be a lot of changes in the beginning and when things settle down I will update my assets using ECS.
     
    3dship and John-G like this.
  31. Josho_O

    Josho_O

    Joined:
    Nov 14, 2017
    Posts:
    2
    Hi there,
    I am trying to use Advanced water from standard asset with DWP. After following all the instructions from manual. Rudder is rotating but boat isn`t moving. Can you tell me any thing i`m missing ??
     
  32. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    Ah, it seems that this is a small bug that arises when single throttle is used (as in W key) and engines are set to LeftThrottle and RightThrottle. I will immediately push a small patch with this fixed but if you want to solve it just set both engine's mapping to "Throttle":

    upload_2018-7-10_13-25-55.png
     
    Last edited: Jul 10, 2018
  33. Panzerking

    Panzerking

    Joined:
    Jul 24, 2014
    Posts:
    5
    Need some help, fellas. Just updated to the new version, after buying the last. Can someone post pics of their input settings? I don't see anything in the manual about it, either. Normally that kind of stuff is already set up.
     
  34. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    I assume you are talking about the boat controls for the demo boat controller? Check the post above you and that might be the problem if your throttle is not working.

    If we are talking about the optional axes for thrusters and such, check the InputHandler.cs for used axes.
    Demo ship controller can use the following:
    • Vertical
    • Horizontal
    • BowThruster
    • SternThruster
    Those all are just the standard axes in the Unity input manager.
     
  35. Panzerking

    Panzerking

    Joined:
    Jul 24, 2014
    Posts:
    5
    Ok, figured it out. You have to add 'BowThruster' and 'SternThruster' axes to the input settings or the demo scene will just show errors in the console and the boats won't move. Worked fine once I did this. Please add a note about setting up input the next time you update the manual. :)
     
  36. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    Will immediately change and push that, along with a change so that the error is not thrown in such case.
     
  37. 3dship

    3dship

    Joined:
    Jun 17, 2017
    Posts:
    7
    Hi,
    What are the changes of the new patch 1.2 ?
     
  38. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    • Addition of the water interfaces out of the box for most used water systems.
    • Fix for the propeller thinking it is not in water.
    • Changeable WaterFX rendering queue.
     
    3dship likes this.
  39. holdingjason

    holdingjason

    Joined:
    Nov 14, 2012
    Posts:
    135
    Any chance someone has played with this for a sailing ship. Would love some default values and setup for something with sails vs motor. Thanks.
     
  40. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    Sailing ship would do as well as a motor boat. The script for controlling the ships was added to the asset as an addition to demo the water physics but the asset sometimes gets confused as ship simulator asset from my experience. What DWP is is an universal water physics solution that uses rigidbodies as the base and as such additional forces - including those from sails - can easily be added by simply using Rigidbody. AddForceAtPosition(). Now it isbon you how realistic you want the sails to be but using a wind vector and taking the dot product of it and the normal to the surface of the wind to determine force along with force falloff as speed of the ship reaches the wind speed would be one simple way to do it.
     
  41. rbeyer3

    rbeyer3

    Joined:
    Apr 3, 2018
    Posts:
    2
    Looks like the latest download of this from the Asset Store has the wrong WaterInterface.cs in the zip file for the Ocean Community shader (the one in the Zip file is for Aquas). Can you update the download or tell me where to get the latest version of that? I modified it in the meantime to use the
    Ocean.GetWaterHeightAtLocation2(x, z);
    , I tried the choppy one but it seemed to make the object bounce a lot.
     
  42. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
  43. Deleted User

    Deleted User

    Guest

    Hello,

    There is a bug when driving boat with keyboard keys. Slowly boat turns to the left even for cases when 'A' button is not pressed. It can be checked by driving boat straight forward and looking at boat 'Y' axis rotation from editor.

    Thanks in advance.
     
  44. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    Thank you for reporting this but in fact it is not a bug. Since the DWP works based on the mesh data (vertices, tris, etc.) and the mesh in question is not symmetrical there is a bit more drag on the left side than on the right side. Can be corrected by moving the engines by a small bit to the left side (0.001 or so). Hope this solves your problem.
     
  45. Deleted User

    Deleted User

    Guest

    Understood,

    But It's almost impossible to have adjustment for which torque effect minimizes to acceptable level. By the way the problem exists even for the sample scene with the difference that boat turns to the right. We're trying to reach real world water physics by adjusting all possible parameters (we understand that it's quite difficult), but described issue is the only obstacle to reach that.

    Thank you.
    Regards.
     
  46. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    True, even in the demo scene models are far from perfect and symmetrical, and mesh decimation algorithm always causes some small inaccuracies. I have not put too much time into aligning the models in the demo scene to go perfectly straight, but a minute or two of adjusting will fix that. This is just the way the asset works and I have kept far away from any trickery to keep objects floating, but using only forces and rigidbodies has (fortunately small) drawbacks.
     
  47. danutz4web

    danutz4web

    Joined:
    Dec 1, 2013
    Posts:
    4
    Hi,
    I just imported into a new project and build it for android.
    Without any changes it looks like this:

    watter1 (2).png

    How can I fix this?

    Thanks for this great package!
     
  48. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,685
    It seems that Unity, for one reason or another, did not put the used shader into the build and that is the reason you got that result. The shader used for foam is WaterFX/WaterParticle and can be added by going to Edit > Project Settings > Graphics > (Scroll Down). Add WaterParticle shader to 'Always Included Shader' list and you will be good to go.
     
    danutz4web likes this.
  49. danutz4web

    danutz4web

    Joined:
    Dec 1, 2013
    Posts:
    4
    Thanks, that was it. Now it works!
     
    NWHCoding likes this.
  50. GorkaChampion

    GorkaChampion

    Joined:
    Feb 6, 2018
    Posts:
    103
    Hi, Just bought it and add it to a small boat and works great.
    My question:
    I want to add this also to a big ship where you can also walk over the deck of the boat. So the collider and the mess is quite big and complicated. My question is: ¿Can you use this system to Skipper it and walk with your thirst person at the same time? (At least either pilot or walk) Do the colliders or meshes interfiere each others? I have tried a bit but with no success at the moment, thanks.
     
    Last edited: Sep 12, 2018