Flashlight Night Vision Script

Hi all! I have a script (below) to make the ambient light change colors to represent night vision in my game on the player’s HUD. I’m new to coding, and I need help to make it so when the player turns on night vision, the spotlight (flashlight) they are holding turns off. Is there any way to do this? Changes to script and advice are welcome. Thanks!

Here is the night vision script:

private var currentColor    : int = 0;
        var changeTime      : float;
        var colors          : Color[];
 
 
function Update () {
    RenderSettings.ambientLight = Color.Lerp (RenderSettings.ambientLight, colors[currentColor], changeTime*Time.deltaTime);
 
 
    //this is just to test
    if(Input.GetKeyDown(KeyCode.N)){
        NextColor();
    }
 
}
 
function NextColor(){
    if(currentColor>=colors.length-1){
        currentColor = 0;
    }else{
        currentColor +=1;
    }
}
 
function SetChangeTime(ct : float){
    changeTime = ct;
}

I am not sure if I understand your question but yes, of course it is possible to switch on night vision and switch off flashlight and vice versa. Lights can be turned on or off simply with game object’s enabled variable. For night vision I would suggest a post-processing effect rather than using ambient light. I think you don’t get the desired results just by changing ambient light (and in addition, it makes using lightmaps difficult). Here are couple of links how you could implement night vision:

http://forum.unity3d.com/threads/110177-RELEASED-Aubergines-Replacement-Shaders-for-Unity-FREE-amp-PRO

http://wiki.unity3d.com/index.php/GreenNightVision