- Home /
How do I make a boat that doesn't let water enter?,How do I make a boat that water cant get in to
I've made a boat in blender, imported a water asset from HolyShift, and wrote a quick script to make it float. Now my issue is that my boat lets water into it. I've done some research and only found a lot of suggestions to make custom shaders, and none of mine have worked. Does anyone know how to properly do this? I can get as far as creating a customer shader on a material but then don't really know what to do in Cg. Alternatively does anyone know an easier way to do this? Thanks in advance.
Answer by Magso · Dec 30, 2019 at 05:42 PM
The easiest way would be to alter the renderQueue of the boat's material so it renders over the water when the camera is near to it. The renderQueue
would have to be reset when the camera is further away because leaving it would cause the boat to be rendered over other objects that it's behind.
I just checked and saw that I have the boat set at 2000 in the render queue and the water set to 3000, but I can still see the water through it. I tried using my own custom shaders and it still didn't work.
Boat has to have higher render queue, not lower
Answer by Koen-Matthijs · Dec 30, 2019 at 07:53 PM
You use a depth mask shader for this type of rendering. We've used the example that's published on the Unity3D Wiki to achieve exactly that : http://wiki.unity3d.com/index.php/DepthMask?_ga=2.206827987.1753848549.1577525989-100160873.1557425811
Regards,
Koen Matthijs
I tried this out, it still didn't take. I'm starting to suspect it may be something in the scripting of the water asset I downloaded. I may just use a different water prefab/figure out how to generate my own. Thanks for the help nonetheless.
Just in case anyone ran into the same issue I did: I just switched out the Prefab and it was the asset I had imported, the Water 4 asset in Unity's Standard Assets didn't have the same issue. Thanks for your help regardless!