- Home /
Why might a pointlight not come back on when re-enabled after being disabled?
I have a pointlight in a prefab gameobject missile. The first time I use the object, the light works. Next time, it does not, though the editor shows the light to be becoming active in the hierarchy view, and correctly placed.
I have a projectile prefab with a point light attached. In the projectile script, I have an explosion prefab instantiated.
I create 5 instantiations of the projectile and store them in an array. I loop through the array as I am firing the projectiles, and am careful not to fire missiles that are already in the scene.
When a projectile hits something I turn off its renderer and start an explosion. When the explosion is finished, I Setactive = false on both the missile and the explosion.
when I fire the projectile, I Setactive=true and turn its renderer back on.
The first 5 missiles I fire, the light works fine. But on subsequent shots with the same missile I get the missile, but not the light. The editor, however, shows the light to be active and correctly placed on the re-activated missile(s).
Answer by DrJBN · Mar 10, 2021 at 07:01 PM
I have discovered that the problem is not the missile- that seems to be working. It is the explosion clones. The pointlight is not getting cloned. Below in the Hierarchy you can see the Sharps_impact attached to the Millerian. Further down, parented to the Nicolosia_station are the Sharps_impact(Clone) s, and they seem to be absent the point light.
Your answer
Follow this Question
Related Questions
Prefab disables a script out of runtime. 0 Answers
random respawn and respawn delay 1 Answer
Breakable objects are still broken after level reset 2 Answers
Scripts/buttons getting old (prefab?) values of variables 1 Answer
Not sure how to change color of individual prefab instance after it was touched 0 Answers