How to enable/disable blur effect with script

Hi,

I wanted to enable the bluroptimized script in my OnTriggerEnter() function but ontriggerenter function doesnt attached to my camera it attached to another object so i want to reach my camera through the other object’s script. And after the player gets out of the zone i want to disable it again. I tried GetComponent(BlurOptimized).enabled = false but it errors
here is my ontriggerenter function

function OnTriggerEnter (Col : Collider)
{
	if(Col.gameObject.tag == "Player")
	{
		enterCollider = true;
		Debug.Log("Is inside collider");
		;
	}
}

function OnTriggerExit (Col : Collider)
{
	if(Col.gameObject.tag == "Player")
	{
		enterCollider = false;
	
	}
}

Thanks for help :slight_smile:

How to enable/disable blur effect with script

Create a new script on the camera. In that script create two public functions “TurnBlurOn” and “TurnBlurOff”:

public function TurnBlurOn ()
{
       GetComponent(BlurOptimized).enabled = true; 
}

public function TurnBlurOff ()
{
       GetComponent(BlurOptimized).enabled = false; 
}

To turn off/on blur send a message to camera :

Camera cam = Camera.main;
cam.SendMessage("TurnBlurOn"); // turns blur on
cam.SendMessage("TurnBlurOff"); // turns blur off