Game Development Reference
In-Depth Information
Adding a flashlight to a weapon
Flashlights have been man's best friend to combat darkness since the invention of electricity.
A flashlight can even be turned into a weapon, as we saw with 2010's release of Remedy's
Alan Wake .
In the following recipe, we'll be creating a flashlight that can attach to the pawn, as well as a
weapon, and be toggled on and off with any key of your choice.
Getting ready
Start by creating a new class called WeaponFlashlight and have it extend from
SpotLightMovable . Also make it non placeable. Non placeable means that it cannot be
dropped onto the map. Essentially it's there to keep things clean for the level designers, and
avoid confusion as to how something should or should not be used.
For this recipe, we'll have to make small modifications to our TutoialPawn class, in addition
to creating one new class, which is our actual flashlight.
class WeaponFlashlight extends SpotLightMovable
notplaceable;
How to do it...
1.
SpotlightMoveable already has all of the functionality that we'll need, so we're
only going to adjust a few of the default properties.
DefaultProperties
{
Begin Object Name=SpotLightComponent0
// Sets the light color
LightColor=(R=200,G=200,B=200)
InnerConeAngle=10.0
OuterConeAngle=20.0
End Object
// Cannot be deleted during play.
bNoDelete=false
}
We decrease the RGB value of the light down from a full 255 to 200 so that we don't
have a blinding white light. I prefer a softer white with a subtle shadow. The inner and
outer cone angles will also greatly affect how the light is displayed on screen. Play
with the values for a bit to really get a feel for what works best for your needs.
The only things left to do from here are additions and alterations to our
TutorialPawn class.
 
Search Nedrilad ::




Custom Search