- Home /
Question by
Manco Capac · Mar 01, 2013 at 02:48 PM ·
renderersettingsfogenabled
Enable fog from sccript
I need to enable for if player is below a specific position. Here's the script, but it's not working...
var position : float;
var underwater : GUITexture;
var underwater : Transform;
var water : Transform;
function Update(){
position = GameObject.Find("Camera1").transform.position.y;
if(position <= 2001){
underwater.enabled = true;
underwater.renderer.enabled = true;
water.renderer.enabled = false;
RenderSettings.fog = true;
} else{
underwater.enabled = false;
underwater.renderer.enabled = false;
water.renderer.enabled = true;
RenderSettings.fog = false;
}
}
Comment
as a general coding matter, you can't just say "if < 2000"
you need to introduce a state - a boolean that knows whether you are underwater.
<2000 is underwater(that's the water level)...
anyway the GUI part works :-/