Time for action – Creating a toggleable flashlight
We'll be working in our AwesomePawn
class for this, but first, let's set the mood.
Open
AwesomeTestMap
in the editor.Select all of the lights, and in their properties set Light | Light Component | Brightness to 0.3.
Rebuild the map by clicking on the Build All button in the top toolbar.
Save the map and close the editor.
Open
AwesomePawn.uc
in ConTEXT.We'll need a variable to store our light component, so let's add it:
var SpotLightComponent Flashlight;
Now let's add the Component to the default properties:
Begin Object Class=SpotLightComponent Name=MyFlashlight bEnabled=true Radius=1024.000000 Brightness=1.90000 End Object Components.Add(MyFlashlight) Flashlight=MyFlashlight
Compile the code and run the game. We have a flashlight!
Now to toggle it. We can use an already existing function for this,
Use()
. It's inPlayerController
, so we'll have to override it in ourAwesomePlayerController
class. If it's already there, then change it to the...