Game Development Reference
In-Depth Information
UpdateEyeHeight() takes Deltatime as a parameter and updates each frame.
With Flashlight.SetRotation() we set the rotation to use Controller.
Rotation , and then offset it slightly so that it appears as though the light is
coming from our pawn's helmet.
5.
We've got our flashlight set to our pawn, but we need a way to turn it on and off now.
Add the following function to your class:
/********************************************************
* Turns the light on and off
********************************************************/
exec function ToggleFlashlight()
{
// If the light is off...
if(!Flashlight.LightComponent.bEnabled)
{
// Then turn it on
Flashlight.LightComponent.SetEnabled(true);
'log("TOGGLE FLASHLIGHT ON");
}
else // If it's already on
{
Flashlight.LightComponent.SetEnabled(false);
// Turn it off
'log("TOGGLE FLASHLIGHT OFF");
}
}
exec function tells us that this function can be called by the player
through a key press. We're stating that if the light is off, then when we select
our ToggleFlashlight key that we're about to define, and then turn it on.
Otherwise, if it's already on, then turn it off.
We need a way to toggle the flashlight on now though! This is a quick fix.
Browse to your .ini files. We're going to be looking for DefaultInput.ini .
This can be generally found under the file path, UDKGame/Config .
6. Open up that file and scroll down until you see the key configurations. Right above
the text marked BINDINGS THAT ARE REMOVED FROM BASEINPUT.INI add
the following code:
;--------------------------------------------------------
; CUSTOM BINDINGS FOR TUTORIALS
 
Search Nedrilad ::




Custom Search