Automatic and Manual Torches

By LadylexUK

In many action adventure and FPS games the player, after collecting the acquired item, automatically lights a torch, glow stick or other light source so that they can see in dark places. Generally this is in dark caves or buildings without lighting. Creating a torch is straightforward, the difficulty comes to deciding on the method of when the torch is lit and when it is not. The obvious answer is to use a trigger zone (light torch when the player is in the trigger zone, and turn it off when they are not), however they are limited in size and occasionally the area you want to light is bigger than the trigger zone. You could use a boolean variable that is set  to true when you enter the place and false when you leave. Remember you will need 4 trigger zones, one to activate and one to deactivate, and also another  one at the entrance and exit in case the player turns around. However other methods include detecting an object or terrain above the player’s head or detecting the brightness setting, or very basically not having an automatic torch and using a button control to turn the torch on and off.

Here are all of the methods.

The torch.
The torch prop has an animation of being lit when powered on, but it does not give off light. Attach a lightbulb to the torch and attach a power connector as well, so when the torch power is on the lightbulb power is on. For a flame style torch set the light to flicker and possible have a red color to the light to match the flame.

You can make your own torch out of various objects. Use power on commands to light the lightbulb you attach to it. You can also make the lightbulb visible if your design uses a bulb.

In torch brain

  1. WHEN [IWP: player][boolvar: torch on] DO [power on]
  2. …WHEN DO [IWP:player][equip][me]
  3. …WHEN [else] DO [power off]
  4. …/…WHEN DO [IWP:player][unequip][me][to inventory]

Now this torch is a hand held one that will remove any weapon you are holding and drop it on the ground. If you want the player to hold the torch in his left hand then attach the torch to the players left hand. Move it into position so it is in the players hand the best you can (you will need to rotate the torch). Then use this kode instead

  1. WHEN [visible] DO [collidable][equals][true]
  2. …WHEN [else] DO [collidable][equals][false]
  3. WHEN [IWP: player][boolvar: torch on] DO [power on]
  4. …WHEN DO [visible][equals][true]
  5. …WHEN [else] DO [power off]
  6. …/…WHEN DO [visible][equals][false]

It looks a little awkward when he is running about but looks good when he is stopped as he holds the torch out in front.

For a gun torch just attach a lightbulb to the gun (you do not need the power connector) and in the gun brain

WHEN [IWP: player][boolvar: torch on]  DO [IWP: lightbulb][power on]
…WHEN [else] DO [IWP:lightbulb][power off]

Method 1: Trigger zones

At the entrance to your dark area place 2 logic cubes. Cube 1 trigger zone is just outside the area. Place Cube 3 and 4 at the exit.

Cube 1 and Cube 4
WHEN[started to] [in trigger zone][player] DO [it][boolvar: torch on][equals][false]

Cube 2 and 3
WHEN [started to][in trigger zone][player] DO [it][boolvar:torch on][equals][true]

Method 2: Brightness setting

You will still need the trigger sensors when entering and exiting an area where the brightness setting is changed, but this will also activate if you are using a day/night cycle with brightness settings.

In trigger zones
Cube 1 and 3
WHEN [started to][in trigger zone][player] DO [brightness][equals][-10]

Cube 2 and 4
WHEN[started to] [in trigger zone][player] DO [brightness][equals][0]

In player brain

WHEN [brightness][less than][0] DO [boolvar:torch on][equals][true]
…WHEN [else] DO [boolvar:torch on][equals][false]

Method 3: Detect above players head

In player brain

WHEN [raycast hit][direction][up] DO [boolvar:torch on][equals][true]
…WHEN [else] DO [boolvar:torch on][equals][true]

Note: The object does not need to be visible to be detected. So you could have an area of open ground with a lit torch if you place an invisible thin primitive prop overhead.

Method 4: Manual Torch

In player brain

WHEN [left bumper][pressed] DO [toggle][boolvar:torch on]


Comments are closed.

Website Powered by

Up ↑

%d bloggers like this: