Unity Underwater

Hello Everyone, I have created a script to get unity to go Underwater

Here it is

var underwater : Color;
var thickness : float;
var water : string

function Update () {

if(GameObject.FindWithTag("MainCamera").transform.position.y < GameObject.FindWithTag("Liquid").transform.position.y){
RenderSettings.fog = true;
RenderSettings.fogColor = underwater;
RenderSettings.fogDensity = thickness;

}

if(GameObject.FindWithTag("MainCamera").transform.position.y > GameObject.FindWithTag(water).transform.position.y){

RenderSettings.fog = false;

	}
}

Just set the Color to some variation of blue and the density to be in the 0.1 - 0.3 range then
Tag the MainCamera and your Water Source and you’re all done

Any reason why you don’t use camera.main ?

Good you´ve shared it but this script was posted in the wiki before.

A suggestion to improve would be using trigger regions to turn the fog on only when inside the region.