So this is kind of specific…
I have a script which when a bool is set to true within the script, it changes materials on an array of objects to an emissive material.
The problem is when I put the code in the update and wait for the bool to be checked, the materials DO change to the emissive material, but its light does not affect any surrounding objects.
If I run the code in the start function the lighting will affect surrounding objects, but not when I’m running it in the update.
This first image is what the emissive lighting should be doing
This second image is what is actually happening in game when the emissive materials have been changed.
What could be the issue?
public class PowerGenerator : Repairable
{
public Material _emissiveMaterial;
public GameObject [] _lights = new GameObject []{};
void Update()
{
PowerOn();
}
private void PowerOn()
{
if(_currentDurability == _maxDurability)
{
isRepaired = true;
}
if(isRepaired)
{
foreach(GameObject light in _lights)
{
light.GetComponent<Renderer>().material = _emissiveMaterial;
}
}
}
}