plus minus gleich

Electrolysis


Engine: Unreal Development Kit

Subject: Kismet Scripting

Estimated Time Required: 20 Minutes

This tutorial explains how to use Kismet, Unreal's scripting system, to create a light that toggles on and off



What is Kismet?


Kismet is Unreal Development Kit's scripting system. A scripting system lets you bring your game to life by adding visual effects, making sounds play, moving objects in the level, and other exciting things. For this tutorial, we're going to use Kismet to make a light that switches on and off when you touch a trigger. Below is a three part video explaining how to do this, as well as a step by step picture tutorial. Feel free to use whichever you prefer.








Part 1: Place the Trigger



Step 1: Start up UDK and click on the Asset Browser


The Asset Browser is where you can find all of the in-game objects you can put in your world. You can add lights, triggers, spawn points, models, weapons, and so on from here. For now, we're going to use this the Asset Browser to add a trigger to the level. When you click on this, a new window should pop up with the Asset Browser.



Step 2: Click on the Actor Classes tab


The Actor Classes tab is where you can find the Trigger we're looking for. Click on the Actor Classes tab to open a list of different things you can add to your level.



Step 3: Find "Trigger" in Actor Classes


Click on the "Trigger." Once you click on it, you can place it in the world.



Step 4: Place the Trigger in the world


Right click in the world where you want to place the trigger. This menu will show up, then click "Add Trigger Here" to put the trigger down. You should now see your trigger in the world.



Step 5: Make the Trigger visible


We can see the Trigger in the editor, but when you actually play the game, the Trigger will be invisible. We need to make it so you can see the Trigger in game. Click on the Trigger and press F4 to open up the options for the Trigger, then click "Display."


Then, uncheck the "Hidden" checkbox to make your Trigger visible in-game.

Now your Trigger is ready and visible! On to Part 2: Placing the Light.



Part 2: Place the Light



Step 1: Find "PointLightToggleable" in the Asset Browser


Now we are going to use the Asset Browser to add a Toggleable Pointlight to the level. This is a special kind of light you can toggle on and off. Open up the Asset Browser and click on "PointLightToggleable."



Step 2: Add the Light to your level


Like when you did with the Trigger, right click on where you want to put your light in the world, then click "Add PointLightToggleable Here." Now, your light is in the level, but we have to move it a little before it's ready. The light is inside the ground, so we'll have to move it out of the ground.



Step 3: Move the light out of the ground


Click on the light, and three colored arrows will appear on top of it. These arrows let you move the light left, right, forward, backward, up, and down. We're going to use them to move the light out of the ground. Click and drag the vertical arrow upwards to move the light out of the ground. Now that we have everything in our level, we can move on to Part 3: Setting up the Kismet script.



Part 3: Setting up the Kismet script



Step 1: Open Kismet


Now that we're ready to open Kismet, click on the K+ button on the top of the screen. This opens up your Kismet script window.



Step 2: Select the Trigger


With the Kismet window open, click on your Trigger.



Step 3: Add the Trigger to Kismet


Right click in your Kismet window, and a small menu will pop up. We're going to mouse over "New Event Using Trigger_0", then click "Touch".

Once you click "Touch", you'll have your first Kismet node! This node is the first part of our Kismet script. However, normally triggers can only fire once in Kismet. We'll need to go in and modify the node to let it trigger as many times as we want.



Step 4: Change the Trigger to fire every time it's touched


Left click on the Kismet trigger. This opens up the options for it in the lower left corner of Kismet.

Click on "Sequence Event." This opens up a list of Trigger options for you to play with.

In "Max Trigger Count", change the number from 1 to 0.

And now, your Trigger is finally ready! Now we can add your light to Kismet as well.



Step 5: Select the Light


With the Kismet window open, click on your Light.



Step 6: Add the Light to Kismet


Right click in your Kismet window again, and this time, click "New Object Var Using PointLightToggleable_0."

Now you have your light in Kismet as well! Now we'll need one more node- the "Toggle" node.



Step 7: Add the Toggle node to Kismet


We're going to add a special "Toggle" node to Kismet, to let Kismet know that we want to turn the light on and off.

Right click in your Kismet window again, and this time, mouse over "New Action."

Then, mouse over "Toggle."

Finally, click "Toggle" in the last list that pops up.

And now, you have a Toggle node in Kismet! Now that we have everything we need in Kismet, it's time to move on to Part 4: Hooking up the Kismet script.



Part 4: Hook up the Kismet script



Step 1: Hook up the Trigger to the Toggle node


Since we want the light to turn on and off when someone walks into the Trigger, we're going to hook up the "Touched" node to the "Toggle" node. To do that, we just need to click and drag from the small "Touched" nub on the Trigger to the "Toggle" nub on the Toggle node.



Step 2: Hook up the Toggle node to the light


Now we have to let the Toggle node know that we want it to toggle the light. To do that, we'll just need to connect the "Target" nub on the Toggle node to the point light variable in Kismet. Click and drag from the "Target" nub to the PointLightToggleable object.



Step 3: Build, save, and test your level!


Your level is now ready for testing! We're now going to build the level, save it, and test it.

Click on the "Build All" button and wait for the editor to tell you the level is fully built.

Once the level is built, click on the "Save" button and name your level.

Then click on the "Play" button to drop in the game and test it!



Take a look at your light, then walk into the trigger.

Once you walk into your trigger, the light should shut off.

Walk away from the trigger...

Then walk back into the trigger to turn your light back on! You've now scripted using Kismet. Congratulations! This is the tool used to create Gears of War, Uncharted, Batman: Arkham City, BioShock, Borderlands, and other video games using the Unreal Engine. You can use the basics from this tutorial to try any of the following, which will be covered in more advanced tutorials:


  • Toggle a static mesh from Visible to Hidden, and vice versa
  • Play sound effects when the player enters a certain area in your level
  • Animate the meshes in your level to do something cool
  • Fire weapon projectiles at any target
  • Play a particle emitter, such as fire, steam, or rain


Good luck, and have fun scripting!

E-mail