The bug I fixed this weekend was raised by my girlfriends brother, who said to me: “Why does the torchlight illuminate the other sides of the walls?”
It was because of the way I have represented the torchlight within the game, simply as a single very large image which rotates with the main character. This image makes everything darker except where the torchlight is.
Not the most elegant solution, but I implemented it quickly when I wanted to see what the game looked like with a torch, and it stuck after that. I’d imagine I’m going to have other problems in the future with this kind of implementation, such as the fact that objects won’t display shadows innately, but I’ll deal with that if it comes up.
As a result, however, it meant that the image illuminates the ‘roof’ and other side of the walls when you are close enough, which looks a little funky.
The solution was easy enough; split my wall tiles into 2 sprite game objects, with one part below the vision image and one part above. This way I can split the sprites into things I want to be illuminated by torchlight (the wall and the door) and things I don’t want illuminated (the white roof boundary).
The new game objects are children of the original one, so they use their parent’s location, and are always situated in the right spot without having to be initialised manually. They also have a new sorting layer “Wall3”, which is situated ontop of the “Vision” sorting layer.