Introduction to Kismet Sai-Keung Wong Reference: Mastering Unreal Technology (MUT)
Contents • What is Kismet? • Examples
Introduction to Kismet • A visual scripting system • Easy to use • Programming experience is not required. • Examples, • Design simple queries/tasks for players • Turn on/off light sources • Change materials of a static mesh • Activate complex event sequences
Introduction to Kismet • A network of sequence objects (序列對象) • Sequence Objects: • Define specific functions • Send signals to each other • How to use? • Make sure you understand clearly your purposes • Then everything is easy to manage
A simple example:Turn on/off a spotlight • Purpose: • The player touches a trigger • Turn on a spotlight • Need to do: • Add a trigger • Add a togglable spotlight • Add a point light with low intensity (dim) • Add a start position for the player • Use Kismet to define the event sequence for the trigger and the spotlight
A simple example:Turn on/off a spotlight • File -> New -> Additive • Create an additive brush (512x512x64) • Create the geometry using the additive brush • Create a point light • Place it at the center of the newly created geometry and move upwards a bit • Change its intensity to 0.5 • Change its radius to 480
A simple example:Turn on/off a spotlight • Add a trigger • Set it as visible • Press F4->Display->Hidden (don’t check it) • Add a SpotlightToggleable (可開關 spotlight）。 • Content browser->actor->light->spotlight->SpotlightToggleable • After creating the spotlight, change its properties • Disable it (F4->light->lightcomponent->Enabled? NO) • Brightness : 4.0
A simple example:Turn on/off a spotlight • Now, create an event sequence using Kismet • Select the trigger • Open the Kismet editor • Right click (click right mouse button)->New event using trigger_0->Touch
A simple example:Turn on/off a spotlight • Go back to the level editor • Select the SpotlightToggleable • Go back to Kismet • Right click->New action->toggle->toggle • Then, right click ->New Object Var Using SpotlightToggleable
A simple example:Turn on/off a spotlight • Now, connect the sequence objects by dragging lines from the connectors • Press left mouse button at one connector and move the cursor to another connector. Then release the left mouse button • Connect “Touched” of “Tigger_0 Touch” to “Turn On” of “Toggle” • Connect “UnTouched” of “Tigger_0 Touch” to “Turn Off” of “Toggle” • Connect “Target” of “Toggle” to SpotlightToggleable_0 • Save, build light maps and test the game level
A simple example:Turn on/off a spotlight • Test the game level • When the trigger is touched, the spotlight is turned on. • But it is not turned off if the trigger is untouched. • To solve the problem • Go back to kismet • Click “Tigger_0 Touch” • Change “Max Trigger Count” to 0 (infinite) • Save and test the game level
A simple example:Turn on/off a spotlight • Now, add a log action to show messages to players (Misc -> New Action -> Log)
A simple example:Turn on/off a spotlight • Input “Spotlight status is changed” in “Obj Comment” of “Log”. Save and test the game level
A simple example:Turn on/off a spotlight • Now, add a position for the player to start to play the game. Place it at a corner. • In level editor • Right click->add actor->add PlayerStart • Save and test
Sequence Object • Input/Output connectors • Left connectors: usually for input signals • Only one input, called as “In” • Purpose: Activates other events • Right connectors: usually for output signals
Sequence Object • Example: Toggle（開關） • Has many inputs, depended on the functions of the sequence object • Example, Condition • Has many outputs • Inputs (squares) & Outputs (triangles) at the bottom Purpose: interact with variables
Types of Sequence Object • Event（事件） • Actions（動作） • Variables（變量） • Condition（條件） • Matinee
Events（事件） • Activate a signal to start a sequence • Something occurs in the game levels • Examples: • Players touch an object • Players toggle a trigger • Etc.
Actions（動作） • Associate with event sequences • Perform certain tasks, e.g. • Change materials of an object • Change the value of a variable • Teleport a player to other place
Variables • Variables（變量） • Store data • Can be modified in a sequence • Example, • Use a variable to represent a player • Use a variable to represent a teleporter
Variable Types • Boolean：红色； • Integer：青色； • Object（對象）：紫色； • String（字符串）：綠色； • Vector（矢量）：黄色； • Union（聯合体（無類型））：白色
Conditions（條件） • For testing purpose • Based on the results, control the flow a sequence
Matinee • Matinee • Control Matinee sequence
Kismet Sequence Flow • Event and action sequences • An event sequence calls an action sequence • An action sequence calls another action sequence • Etc. • There must be a starting point for activating other sequences • Action sequences cannot be activated themselves on their own.
Sound • Touch a trigger • Turn on a light source • Play a sound clip • In Kismet • Right click->new action->sound->play sound • Connect “Out” of “Toggle” to “Play” of “Play Sound”
Content browser->sound cues->select a sound clip In Kismet, “use selected object in content browser for “Play Sound” object. Save and test.
Sound • Assign two sounds for “Touched” and “UnTouched”, respectively.
Kismet: Changing Materials • Change the material of an object • Content browser->static mesh->select a static mesh • Go back to level editor • Place the static mesh • Content browser->create MaterialInstanceConstant
Create and assign a material as the parent of the newly created MaterialInstanceConstant
Define a scalar parameter named as “MaterialControl”. Set its value as 1.
Kismet: Changing Materials • Assign the newly created MaterialInstanceConstant to the static mesh
Kismet: Changing Materials • Now, • Create a Kismet sequence to change material of the static mesh • Create a “touch” trigger event for the trigger
Kismet: Changing Materials • Right click->new action->material Instance->Set ScalarParam
Kismet: Changing Materials Create two “Set ScalarParam”. Set the Scalar value of one as 1.0 and another as 0.0. Set the Param Name as “MaterialControl”. Set the Mat Inst as the newly created MaterialInstanceConstant
Kismet: Changing Materials • Save and test
Delay action Touch the trigger to change the material. After 3 seconds, the material is changed back automatically.
Kismet: Changing Materials • Level startup event
Simple Example: Spawn • actor的spawning（生成） • Examples, create enemies • Spawn enemies on demand • Spawn static meshes
Simple Example: Spawn • Add navigation points • Actor->pathnode • Add around five. • Then we will assign them to the factory spawn points