- Home /
Underwater Effect Script Removes Skybox and gives no effect
Hey guys So i am working on my game and one of my levels includes wated. (its basically a island ). But i have played the island demo and there is a underwater effect in that demo. i have searched for a script and i found one on the unifycommunity. The script said to attach it to the main camera so i did. when i went into play mode, there was no effect underwater at all and my skybox had disappeared completely. It was saying stuff about water planes and stuff so i didnt know if that had something to do with it. plz if anyone can help i will be so happy as it is a big feature in my game. any video tutorial links would be appreciated aswell. If you require the script here it is: //This script enables underwater effects. Attach to main camera.
//Define variables var underwaterLevel = 7;
//The scene's default fog settings private var defaultFog = RenderSettings.fog; private var defaultFogColor = RenderSettings.fogColor; private var defaultFogDensity = RenderSettings.fogDensity; private var defaultSkybox = RenderSettings.skybox; var noSkybox : Material;
function Start () { //Set the background color camera.backgroundColor = Color (0, 0.4, 0.7, 1); }
function Update () { if (transform.position.y < underwaterLevel) { RenderSettings.fog = true; RenderSettings.fogColor = Color (0, 0.4, 0.7, 0.6); RenderSettings.fogDensity = 0.04; RenderSettings.skybox = noSkybox; }
else {
RenderSettings.fog = defaultFog;
RenderSettings.fogColor = defaultFogColor;
RenderSettings.fogDensity = defaultFogDensity;
RenderSettings.skybox = defaultSkybox;
}
}
This script expressly sets skybox to nothing if you're camera's transform is less than the 'underwaterLevel'. Aside from that, and the fog, there don't appear to be any 'effects'.
Answer by Trigger_unity · Jun 04, 2015 at 08:26 AM
Visit https://gist.github.com/RichardSlater/3860464
it contains a far better script
Your answer
![](https://koobas.hobune.stream/wayback/20220613104440im_/https://answers.unity.com/themes/thub/images/avi.jpg)