- Home /
Changing light Intensity though script does nothing
I've written a script where when the player teleports a Particle effect turns on and a light turns on. To make the light turn on I decided to start the light with 0 intensity then when the script activates turn the intensity to 0.36.
The problem is that even though the object registers the input the light does not change (even though when I inspect the object the intensity = 0.36). I've posted the code bellow to make sure everything is correct, my guess that the lights are pre-rendered and so they cannot be changed during gameplay, however that's just my hypothesis and really have no idea.
Please could someone explain why my light is not changing and how I can fix this.
Thanks!
Code:
using UnityEngine;
using System.Collections;
public class TeleportSectionComplete : MonoBehaviour
{
public Transform exit;
public Transform last;
public GameObject lp;
void OnTriggerEnter ( Collider other)
{
if (exit == last)
return;
TeleportToExit( other );
}
void OnTriggerExit ()
{
Debug.Log("Exit Trigger");
if (exit == last)
last = null;
}
void TeleportToExit (Collider other)
{
last = transform;
other.transform.position = exit.transform.position;
lp.particleSystem.Play();
lp.light.intensity = 0.36f;
}
}
Lights, are not pre-rendered and ofcourse they can changed in the gameplay.
I've come straight from the Source Engine to Unity so it's taking me a while to adjust.
What's more important here is the settings for the light. Since you've verified that the light'sintensity is changing, check the render mode for the light. It should be marked realtime and important.
Answer by robertbu · Feb 17, 2013 at 07:46 PM
How many of these lights do you have? Look at Edit/Project Settings/Quality. Pixel Light Count will determine the maximum number that will be rendered.
Your answer
![](https://koobas.hobune.stream/wayback/20220613092845im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Changing light colour makes it too bright 3 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Interaction between Unity and Universal Windows 10 apps 0 Answers
Script flares onto lights? 1 Answer