void CheckLight() { hits = Physics.OverlapSphere(playerTransform.position, maxLightCheckRadius, lightLayer, QueryTriggerInteraction.Collide); hitCount = hits.Length; lightStrengthGoal = 0f; if (hitCount > 0) { for (counter = 0; counter < hitCount; counter++) { lightSource = hits[counter].GetComponent <LightSource>(); lightStrengthGoal += lightSource.LightStrength(playerTransform.position); } } lightStrengthGoal += torch.LightStrength(torch.transform.position); lightStrengthGoal = Mathf.Clamp01(lightStrengthGoal); lightStrength = Mathf.SmoothDamp(lightStrength, lightStrengthGoal, ref lightVelocity, lightDamp * Time.deltaTime); lightSlider.value = lightStrength; if (lightStrength <= 0f) { wEvent.EndTheGame(); } }