In unity, i have a ship
And i have also water:
I want to make ship float on water, but(of course) what I get is this:
Is there any good way to keep water out of the ship?
Just want to make that water inside ship not displayable.
Maybe there is already answer for my question over the internet, but I had no idea on what do I exactly type in google... and I had also no idea for title of this question, so please don't blame me for unclear title.
Not it looks like this:
I want it to look like this:
I don't use any physics here, the y
coordinate of ship is constant.
To Doh09:
Your code seems to work, what i got is:
But when I run game, what I got instead is:
http://wiki.unity3d.com/index.php?title=DepthMask
Using the code in the above link, I got the result you see in the images below.
I use the 2 scripts below to achieve it.
The SetRenderQueue object sets the render priority during the Awake method. Lower numbers in the render queue means they are prioritized higher.
In the picture the boat has 2500, the depthmask 2700 and the water 3000. Although I might have only had to set the depthmasks, possibly the waters queue, but you can experiment a bit with that.
The shader itself (the bottom script) should be put on a material that your mask uses. You can then make the mask a child object of the boat so it always stays with it and keeps the water in the boat hidden.
SetRenderQueue.cs
DepthMaskShader
For the sake of clarity, here is an image showing the hierarchy as well as the mask object without the shader.
Good luck with your game.