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