Post tutorial RSS UDK Kismet: Flashlight with camera rotation

A short Tutorial for UDK to setup a switchable flashlight that follows the camera.

Posted by on - Basic Client Side Coding

Fist of all you have to copy the following script into a text file and save at your UDK folder under Deveolopment/Src/Engine/Classes as SeqAct_GetPlayerRnL.uc.

class SeqAct_GetPlayerRnL extends SequenceAction;

var vector rotationVector;
var vector locationVector;

// Events

event Activated()
	local SeqVar_Object ObjVar;
	local Pawn player;
	local Rotator viewRotation;

	foreach LinkedVariables(class'SeqVar_Object', ObjVar, "Target")
		player = Pawn(ObjVar.GetObjectValue());
		viewRotation = player.GetViewRotation();
		locationVector = player.GetPawnViewLocation();

		rotationVector.X = viewRotation.Pitch;
		rotationVector.Y = viewRotation.Yaw;
		rotationVector.Z = viewRotation.Roll;



	ObjName="Get Player Rotation and Location"

	VariableLinks(1)=(ExpectedType=class'SeqVar_Vector',LinkDesc="Rotation Vector",bWriteable=true,PropertyName=rotationVector)
	VariableLinks(2)=(ExpectedType=class'SeqVar_Vector',LinkDesc="Location Vector",bWriteable=true,PropertyName=locationVector)

Now you should make a full recompile in UnrealFrontend (make sure the UDK editor is closed it may cause some issues)

UnrealFrontend is located in the UDK folder/Binaries


If thats done start the UDK editor to create a simple map with a Playerstart or open the map you want to implement the Flashlight.

My map look like this i added no light source so you have a better effect of the flashlight:


The next step is to add a Spot Light Moveable go to the ContentBrowser(Ctrl+Shif+F) and select actor classes and search for Spot light movable. Know position it in front of the Playerstart (make sure it is pointing towards the blue arrow).

It should look like this:

If thats done go to Kismet by pressing on the green K+ icon next to the ContentBrowser icon:

the upcoming Kismet window make the sequence look like this:


The blue comments are the location of the Kismet Nodes in the add menu (RightClick in Kismet window)

The Red lines show where you have to connect the variables

The black arrow show how the properties have to be changed(the rest can be the default properties)
After that is done there just one thing that is missing the light. Select the Spot Light Movable in the editor window. Open Kismet press RightClick and select New Object Var Using SpotLightMovable_0
(the number at the end may be different)

To finish this you just have to connect the SpotLightMovable var with the target of Set Actor Location and the target of Toggle.

The Kismet sequence should look like this in the end:

Know you should rebuild the map by pressing the button with the blue cube and the light bulb

Start the map and it should work like that:

I hope this Tutorial was helpful. If you have problems or question on this write them in the comment section. And don't forget to give feedback!

Here you can download the finished result including the script file:
Flashlight Tutorial Finished Result

Also you might be interessted in one of these links:

TheDj245(my youtube channel):
Spotted (game project):
One Man Studio(facebook page):

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.