Unity 3D - Torch

As stated in the previous post about lighting, I am going to be using a gameplay element to aid in lighting the scene.

I will be using a torch.

Creating the torch mechanic was fairly simple. It is a spot light which shines from the player and is linked the the player at all times. I adjusted the component values in order to get a desired outcome:











After this I had to create a script that allows the player to toggle the torch on and off whenever they want with a key press. I included the light in the script and also added the option for sound, so if I decide to have sound effects for the torch I can easily input these. Here is the torch script:












In order for the player to know how to use the torch I added a small UI element that shows a little message at the beginning of the game, which disappears when the player tries to activate the torch for the first time.

Here is what that looks like as well as the script for it:












The torch looks like this when toggled on in game:


Comments