As I alluded to in my last post, yesterday I added the beginnings of lighting to my game – a simple object with a sprite (a lantern) and a point light. Unfortunately, it was not smooth sailing:
My character sprites weren’t being lit properly! They were being lit by the ambient scene lighting but the point light was about as effective as a pair of goggles in an acid tidal wave.
After a while spent experimenting, I determined that my player prefab was Proper Buggered and the only thing for it was to recreate it piece by piece, which worked a treat! Newly-working character lighting in hand, I started including torch placement as part of the dungeon generation. What could possibly go wrong?
Ah… It would appear that Unity does not take kindly to many point lights existing at once.
Simple solution: have them turn on only when the player gets close, and turn off again when they leave the area. Beauty! Here it is in action:
Best bit is, at first glance you can’t even tell it’s doing it, so here’s how it looks behind the scenes:
Until next time!