Light Color Change

I am trying to script a way to half the intensity of a light that is already green (0, 255, 0) to (0, 128, 0).
A member helped me with the syntax however when I run the game the key command doesn’t do anything, I am assuming I have something mixed up.

My project involves 3 lights already on at the start, and when you enter a trigger they turn off, and when you exit they turn on.

I am looking to add another layer in which you enter the trigger and when you hit the down arrow the intensity of the light lowers.

right now my code is as follows:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ChangeIntensity : MonoBehaviour
{

    private Light myLight;
    bool isPlayerInside;
    bool PlayerFiresDown;

    // Start is called before the first frame update
    void Start()
    {
        myLight = GetComponent<Light>();
    }


    void OnTriggerExit(Collider other)
    {
        if(PlayerFiresDown)
        {
            isPlayerInside = true;
            myLight.color = new Color(0, 128, 0);
        }
    }

    // Update is called once per frame
    void Update()
    {
        if (isPlayerInside && Input.GetKeyUp(KeyCode.DownArrow))
        {
            myLight.color = new Color(0, 128, 0);
        }
    }
}

thank you

I see no code that makes PlayerFiresDown true. Same goes for isPlayerInside.

To help gain more insight into your problem, I recommend liberally sprinkling Debug.Log() statements through your code to display information in realtime.

Doing this should help you answer these types of questions:

  • is this code even running? which parts are running? how often does it run?
  • what are the values of the variables involved? Are they initialized?

Knowing this information will help you reason about the behavior you are seeing.

Thank you, the problem appeared to be what you said no true for playerfiresdown, and isplayerinside

Also changed the color to myLight.color = new Color(0, .5f , 0, 1); instead of myLight.color = new Color(0, 128 , 0); which was a far brighter green.

Where would I put Debug.Log(), inside my voids or outside?