Fog with Script

How would I increase the density of the fog in render settings with an OnTriggerEnter? Like:

function OnTriggerEnter (other : Collider) {
   makeMyFogDenser;
}

:stuck_out_tongue: Thanks people.

function OnTriggerEnter (other : Collider) {
   RenderSettings.fogDensity *= 1.25;
}

Something like that.

http://unity3d.com/Documentation/ScriptReference/RenderSettings.fogDensity.html

-Jon

That’s awesome. Thanks!

EDIT: And for our bonus round…

How do I make it so that only a certain gameObject activates that trigger and no others are able to? Thanks again!

Off the top of my head and not tested, one way is you could give that ā€œspecialā€ object a unique name and check the name

function OnTriggerEnter (other : Collider) { 
  if (other.name == "The Special Name") {
     RenderSettings.fogDensity *= 1.25; 
  }
}

Or, you could have another public variable declared as a Collider and check against that

var theSpecialObject : Collider;

function OnTriggerEnter (other : Collider) { 
  if (other == theSpecialObject) {
     RenderSettings.fogDensity *= 1.25;
  } 
}

Or, you could give the object its own special tag and check that.

That works like a charm. Thanks for your help!