This is my first post on the forums. I’m new to Unity and I was wondering how to make an underwater view like in the island paradise demo. I really need help with this! By the way, this is in Unity 2.1 INDIE. Thanks.
The island demo uses a post-processing blur filter for the underwater effect, which isn’t available in Indie. However, that actually wouldn’t be my choice for an underwater effect anyway, since generally being underwater doesn’t make your view all blurry, unless there’s something wrong with the water.
I’d be more inclined to do something like (pseudocode, won’t compile):
function Update () {
if (transform.position.y < waterHeight) {
fogColor = underwaterFogColor
fogDistance = underwaterFogDistance
}
else {
fogColor = normalFogColor
fogDistance = normalFogDistance
}
}
and have the underwater fog color be darker and more blue, with the underwater fog distance being closer so the fog is thicker.
–Eric
Yeah, sounds good, but pretend I have no skill in scripting (which I don’t btw), and have no idea what your saying. How would I go about doing this???
I would advise acquiring skill in scripting then, because otherwise there’s no point in me explaining anything.
–Eric
okay. i’ve tried, but i have yet to succeed. I tried copy+pasting the script, but there were a lot of errors. im guessing that the variables weren’t defined in the example script to put up. just wondering anyway.
–Eric
i don’t know what that means, sorry.
He’s saying the shader being used in the island demo is only available in the Pro version and you wouldn’t want to use that anyway, because it’s slow.
The example he gave is “psuedo-code”, meaning not “real code” but an example of what you’d probably want to write.
Although I haven’t learned Javascript/C# yet, I intend to, since it’s a good skill and really it’s the only way you’re going to be able to make YOUR GAME versus using a game-making-editor and moding THEIR GAME (like with basic TGB or Gamemaker).
I don’t think it’s slow at all, it’s just blurry. ![]()
–Eric
Thanks for clearing it up. I’ll experiment a little with the little knowledge I have so far, plus Unity 2.5 helping out a lot. Unity 2.5 rocks btw, thanks for it higgyb and gang.
Doesn’t the Island scene use fog when you’re submerged by default. If so, just take a look at how they do it.
This is what I used by attaching the script to my camera
Update()
{
var underwater = 500.0;
if(transform.position.y < underwater)
{
color = Color (56.0, 166.0, 198.0, 122.0);
RenderSettings.fogColor = color;
RenderSettings.fogDensity = 0.1;
}
else
{
color = Color (78.0, 142.0, 149.0, 122.0);
RenderSettings.fogColor = color;
RenderSettings.fogDensity = .0004;
}
}
Hahaha, Eric. Apparently you’ve never been swimming off the Jersey shore. ![]()
True.
Most swimming I’ve done has been in Florida.
–Eric
I guess this is a very old post, but lately I get this question from many non programmers too. So I did a small tutorial here :
Hope it helps for non programmers.
i have tried a bunch of different scripts for an underwater effect but when i put all of them on the camera the whole world was covered in fog not just underwater. i entered in the y coordinates too.