How do I make the area under my water (a plane) look like its underwater?

In my game I have an area of water (The water is a plane), It looks realistic, but when I go under that plane and look up, you can’t see it. How do I make it so that not only can it be seen from the below, but also so that everything under that plane has a bluish tint? I am a beginner so sorry if this sounds basic or if it’s not even possible. (I’ve only had Unity for 6 days)

Underwater tutorial: Kostiantyn Dvornik :: Ideas: Unity world's coolest tutorial about water, girls and sky with FREE assets

The simplest solution in your case would be to double face the water plane, so that it would be rendered even from behind: attach the script from this answer to the water plane, and it will become double faced at Start.

The second part is the underwater effect. A very reasonable (and widely used) underwater effect is to turn a bluish fog on when the camera goes below the water plane. This can be done with a script like the one below attached to the player (for First Person games):

var underwaterDens: float = 0.15;
var underwaterColor: Color = Color(0.1, 0.3, 0.4, 1.0);

private var oldFog: boolean;
private var oldDens: float;
private var oldColor: Color;
private var oldMode: FogMode;
private var curWater: Transform;
private var underwater = false;

function OnTriggerEnter(other: Collider){
	if (other.tag=="Water"){ // if entering a waterplane
		if (transform.position.y > other.transform.position.y){
			// set reference to the current waterplane
			curWater = other.transform; 
		}
	}
}

function OnTriggerExit(other: Collider){
	if (other.transform==curWater){ // if exiting the waterplane...
		if (transform.position.y > curWater.position.y){
			//  null the current waterplane reference
			curWater = null; 
		}
	}
}

function Update(){
	// if it's underwater...
	if (curWater && Camera.main.transform.position.y < curWater.position.y){
		if (!underwater){ // turn on underwater effect only once
			oldFog = RenderSettings.fog;
			oldMode = RenderSettings.fogMode;
			oldDens = RenderSettings.fogDensity;
			oldColor = RenderSettings.fogColor;
			RenderSettings.fog = true;
			RenderSettings.fogMode = FogMode.Exponential;
			RenderSettings.fogDensity = underwaterDens;
			RenderSettings.fogColor = underwaterColor;
			underwater = true;
		}
	} 
	else // but if it's not underwater...
	if (underwater){ // turn off underwater effect, if any
		RenderSettings.fog = oldFog;
		RenderSettings.fogMode = oldMode;
		RenderSettings.fogDensity = oldDens;
		RenderSettings.fogColor = oldColor;
		underwater = false;
	}
}

Remember to tag the water plane as “Water”, or nothing will happen.

Look here:
http://forum.unity3d.com/threads/20222-Water-plane-and-flip-texture

This goes into the details and has a sample script and video.

tldr; Make two water planes and flip one upside down…

I had to make some changes to make it work, I do not know why but the standard code posted which used a variable of type transform you blocking at the point “curWater = other.transform;”. Instead of following the correct code to those who need it. Excellent solution in any case! :slight_smile:

 var underwaterDens: float = 0.15;
 var underwaterColor: Color = Color(0.1, 0.3, 0.4, 1.0);
 
 private var oldFog: boolean;
 private var oldDens: float;
 private var oldColor: Color;
 private var oldMode: FogMode;
 private var curWater: GameObject; //CHANGED (Previous: Transform)
 private var underwater = false;
 
 function OnTriggerEnter(other: Collider){
     if (other.tag=="Water"){ // if entering a waterplane
         if (transform.position.y > other.transform.position.y){
             // set reference to the current waterplane
             curWater = other.gameObject; //CHANGED
         }
     }
 }
 
 function OnTriggerExit(other: Collider){
     if (other.gameObject==curWater){ // if exiting the waterplane...

         // CHANGED
         if (transform.position.y + 0.6 > curWater.transform.position.y) {
             //  null the current waterplane reference
             curWater = null; 
         }

     }
 }
 
 function Update(){
     // if it's underwater...

     //CHANGED
     if (curWater && Camera.main.transform.position.y < curWater.transform.position.y + 0.2){
         if (!underwater){ // turn on underwater effect only once
             oldFog = RenderSettings.fog;
             oldMode = RenderSettings.fogMode;
             oldDens = RenderSettings.fogDensity;
             oldColor = RenderSettings.fogColor;
             RenderSettings.fog = true;
             RenderSettings.fogMode = FogMode.Exponential;
             RenderSettings.fogDensity = underwaterDens;
             RenderSettings.fogColor = underwaterColor;
             underwater = true;
         }
     } 
     else // but if it's not underwater...
     if (underwater){ // turn off underwater effect, if any
         RenderSettings.fog = oldFog;
         RenderSettings.fogMode = oldMode;
         RenderSettings.fogDensity = oldDens;
         RenderSettings.fogColor = oldColor;
         underwater = false;
     }
 }

While for those who want the c # version:

public float underwaterDens = 0.15F;
public Color underwaterColor = new Color(0.1F, 0.3F, 0.4F, 1.0F);

private bool oldFog;
private float oldDens;
private Color oldColor;
private FogMode oldMode;
private GameObject curWater;
private bool underwater = false;

void OnTriggerEnter(Collider other){
    if (other.tag=="Water"){ // if entering a waterplane
        if (transform.position.y < other.transform.position.y){
            // set reference to the current waterplane
            curWater = other.gameObject;
        }
    }
}

void OnTriggerExit(Collider other){
    if (other.gameObject==curWater){ // if exiting the waterplane...
        if (transform.position.y + 0.6F > curWater.transform.position.y){
                //  null the current waterplane reference
                curWater = null; 
            }
    }
}

void Update(){
    // if it's underwater...
    if (curWater && Camera.main.transform.position.y < curWater.transform.position.y + 0.2F){
        if (!underwater){ // turn on underwater effect only once
            oldFog = RenderSettings.fog;
            oldMode = RenderSettings.fogMode;
            oldDens = RenderSettings.fogDensity;
            oldColor = RenderSettings.fogColor;
            RenderSettings.fog = true;
            RenderSettings.fogMode = FogMode.Exponential;
            RenderSettings.fogDensity = underwaterDens;
            RenderSettings.fogColor = underwaterColor;
            underwater = true;
        }

    } else // but if it's not underwater...
        if (underwater){ // turn off underwater effect, if any
            RenderSettings.fog = oldFog;
            RenderSettings.fogMode = oldMode;
            RenderSettings.fogDensity = oldDens;
            RenderSettings.fogColor = oldColor;
            underwater = false;
        }
}