Game Development Reference
In-Depth Information
2.
Start off by declaring a variable to reference our WeaponFlashlight .
var WeaponFlashlight Flashlight;
3.
We also need to add some functionality in our PostBeginPlay() function:
simulated event PostBeginPlay()
{
Super.PostBeginPlay();
'Log("================");
'Log("Tutorial Pawn up");
//***** Used for the flashlight *****//
// Spawns the light on the player, setting self as owner
Flashlight = Spawn(class'WeaponFlashlight', self);
// Sets the lights base on at the player
Flashlight.SetBase(self);
// Light is off by default
Flashlight.LightComponent.SetEnabled(false);
// Starts at 75% brightness
Flashlight.LightComponent.SetLightProperties(0.75);
}
We're doing a few things here. First, we're spawning our WeaponFlashlight and
setting our pawn as the owner. Afterwards, we're attaching the light to our pawn,
keeping it toggled to off by default, and dropping the brightness down to 75 percent.
4. The flashlight is attached to our pawn, but we need it to rotate when our pawn
rotates, so let's do that now:
/********************************************************
* Forces the flashlight to use our pawn's rotation
********************************************************/
event UpdateEyeHeight( float DeltaTime )
{
Super.UpdateEyeHeight(DeltaTime);
// Flaslight will use our controller's rotation
Flashlight.SetRotation(Controller.Rotation);
/* Offset the light slightly, so that it looks as
though it is coming from our pawn's eyes/helmet */
Flashlight.SetRelativeLocation
(Controller.RelativeLocation + vect(20, 0, 25));
}
 
Search Nedrilad ::




Custom Search