UDK Documentation: Kismet
READ THE OFFICIAL DOCUMENTATION! This page covers tons more examples that I'll be showing.
Kismet Door
This will cover creating a door opening and closing as the player interacts with it.
I cut a hole in a csg brush to represent where the door will be, and made a basic door static mesh that is a placeholder for now.
Static meshes you want to move must be added as an InterpActor. With the door selected in Content Browser, Right Click > Add Actor > Add InterpActor.
You can also turn any model already placed in a level into a mover by selecting the Static Mesh > Right Click > Convert > Convert StaticMesh to Mover
InerpActors are added without collision. After placing, double click the InerptActor to bring up it's properties (or select and press F4) and set it's Collision Type to COLLIDE_BlockAll. This will ensure you can't enter a door you intend to be closed. You should test this beforehand.
Note, set your actor to it's original position. If you intend for this door to be closed then it should be closed before you begin the matinee process.
With the door positioned, open Kismet (click this icon)
Right click inside of Kismet, and choose New Matinee.
Double-click on the Matinee object that appeared to bring up UnrealMatinee
With this tool, you can setup all sorts of animated sequences from helicopters flying by to all the cameras for a cinematic.
Notice the red triangles here. These represent the entire length of the matinee. Default is five seconds. They can be click-dragged to any time you need for a particular matinee.
If an elaborate cut scene lasts 30 seconds then this is dragged to 30 seconds, but for this simple swinging open door, set it to 2 seconds.
With the InerpActor door selected, right click here and Add New Empty Group. Name this based on what this door opening represents. I named this one A1_door01 because it's the first door (door01) the player encounters in the first apartment building (A1) of this level.
If you look in Kismet at this point, you'll see the door InterpActor Variable (pink circle) is already connected to your Matinee. This InterpActor Variable represents te door in the level. You can right click it and Select in Level to do just that. Additionally, you can select the actor in the editor, right click and Find in Kismet. This will open Kismet and select the InterpActor Variable. This is very useful when working with complex levels.
Next, you need to add a Movement Track which represents the animation of the door opening. So with your new empty group selected, right click and Add New Movement Track.
The thicker black line at in the timeslider controls what time is being displayed. Drag it to the end of the time scale. Back in the editor, rotate the door open to it's fully open distance. In Matinee, select the Movement group and hit 'Enter'.
This is setting keyframes. If you know much about animation this is something you are familiar with. If not, keyframes can be points in time that tell things were to be.
From here you can move the time slider to watch the door open or close. We're done with Matinee for this door. That gave this door it's animation to open, but now we need to tell it to open. We'll do that with a trigger.
Next, we need to set up a trigger for opening this door. There's two way to handle this. We can use the Builder Brush to create a Trigger Volume as at the size which you feel is best for when the door should be activated. You can also add a trigger, but for this door, I simply want it to open when you're in a specifc range, so a Trigger Volume would be the best choice. Note, you can use a trigger, but a trigger volume makes it's activation a lot easier to control by range. By default, Trigger Volumes appear green.
With your trigger volume selected, right click in kismet and add New Event Using [triggername] > Touch.
Be sure to set the Max Trigger Count to 0 for this door. This allows the door to be triggered an infinite amount of times. If left at 1 it will only open once (not even triggering the second time to close).
Plug the Touched into Play and UnTouched into Reverse. whenever you enter the trigger volume the Matinee of the door opening will play. As soon as you step out of it, it will Reverse. Visually, this means if you run through the door it will open smoothly with you, and you will pass through it (as long as your TriggerVolume is the appriate size for the door animation), but if you step into the Trigger Volume and immediately step out, you'll see the door begin to open before closing at the same rate of speed. Pretty cool stuff.
There you have a working door.
Adding a lock and key
I want this door to be locked unless unless I pick up a key. It's always a good idea to write out exactly what you want kismet to do before you build it.
The key/door example is great as they can represent placeholders of major events happening in a level (as opposed to being a key). It's all up to your creativity and amount of work you can put into it. The idea is that if the player does one thing the game rewards them. Here's how we'll do that.
First thing we want to do is place our "key" asset. This is purely for visually feedback of gameplay (let's player see a key). In kismet terms, we are going to trigger an interpactor to hide.
I have skeleton key model that I'm going to place as an InterpActor
, and I'm going to place a trigger on top of it. The trigger icon is pretty large, you can adjust it's drawscale to your preference. Right click, Add Actor > Add Trigger
With the trigger selected, open Kismet, right click and add New Event Using [triggername] > Used. This sets the trigger to not activate until you are in range and press a key (UDK default is 'E').
You can change this key through the .ini files. Additionally, you can set keys through the .ini files and kismet to triggers so that a keystroke activates a UI menu system or throws a grenade made is kismet. The doors here are wild open to creativity if you can dedicate the time.
Unlike the door, which can be triggered multiple times, we only need to trigger picking up this key once. So for this we can leave the Max Trigger Count at 1 (default setting). But, unlike the touch trigger of the door, we have the Aim To Interact option to worry about. If you leave this checked, the player must aim directly at the trigger to activate it. This is good for a small switch or any very specific spot you wish for the player to click. Most of the time, however, you want to uncheck Aim To Interact so the player only has to be in range. This is much better for activating dialog with characters, opening doors, and so on.
If you leave Aim To Interact checked, you MUST be precise to activate a trigger. If the trigger is just floating around the visual trigger (static mesh button or something) then you might thinks your trigger is not being activated because you may be missing the trigger due to aim being important. Again, I suggest this be unchecked for most trigger uses.
A little more information on that:
If you open the properties of a trigger (select and hit F4), under Display is the Hidden checkbox. By default, it's checked because you do not want one of these trigger icons floating around in a level. However, for testing, it's often very useful to see these things. This can be easily achieved by unchecking the Hidden box. Now when you play, you will see this trigger icon.
In Kismet, you can set Obj Comments to anything in kismet. I suggest doing this for most thing just for your own organization. It makes a huge sequence easy to understand. If you check the Output Obj Comment To Sceen checkbox, whenever this sequence is activated, it will log the comment to the screen. Again, incredibly useful for debugging, but not something you want active for a final release. [If you togglehud, obj comments and anything else logged to the screen will not appear, but still visible in the console]
Now we need to tell that trigger to hide the key. Like with most things in the Unreal, there's more than one way to handle this.
We can use a Toggle Hidden New Action > Toggle > Toggle Hidden.
This will hide whatever it's target is as long as it's able to be hidden. This is useful if you want something to eventually be unhidden by another trigger.
Another option is Destroy. New Action > Actor > Destroy.
This does as it says, and completely removes the object forever. This is what we'll be using for this key pick-up because it will never be reappearing on the floor for us to pick-up again.
With your key interpactor selected in editor, right click in Kismet and add new object variable for this key. Link this to the Target, and link the trigger to the Destroy. In game, we can test this by standing over the key and pressing 'E'. The key should disappear.
You can comment in Kismet just like the material editor. I suggest you do this for organization. To do this; Hold Ctrl + Alt, then click and drag select everything you want inside a comment. Once selected, right click and Comment.
At this point visually, we have a key that appears to pick up in game, but it does not yet interact with the door. Let's make them work together.
This simpliest way to do this is to plug the Destroy directly into the door opening matinee play, and remove the door touch trigger. But that is not very interactive as picking up the key is literally opening a door somewhere giving the player no visual feedback.
For this, I'll be using bools. Those with programming experience understand these. In layman's terms, they are a 1 or 0 where as 1 (binary) is True and 0 is False that can be used to set the status of pretty much anything. For this example, by default we'll set the status of the player having picked up this key to False, and once you've activated the trigger it will be set to True.
Using Bools
Right click > New Variable > Bool or Hold 'B' on the keyboard and left click. This will add a Bool. It's fun to say, "Bool".
By default, bools are False. You can make them True by setting the b Value to 1 in the bool's properties.
What we need to do is set the bool triggered by picking up the key.
Add two bools, set one's Var Name to 'Key', and the other to be True.
Next, add a Named Variable, and set it's Find Var name to 'Key'. If setup correctly, the red X will turn into a green check.
Right Click > New Action > Set Variable > Bool. This action allows us to set the status of a variable to be true or false.
Link these up as shown below. What this is telling the game is, the Key variable, by default is set to False, but once this is activated it will be set to True. In other words, it's telling the game the player picked up the key.
And here's how that should appear with the trigger and key:
Besides destroying the key interpactor, now the game knows the key variable is set to true.
Now we need to tell the door about this key.
Start by adding a Compare Bool. Right Click > New Condition > Comparison > Compare Bool
This is linked between the Touched of the trigger and the Play in the Matinee. The Bool is the Named Variable "Key".
The Compare Bool True output goes into the Play of the Matinee, and I added an announcement of "The door is locked." to the False to let the player know they do not have the means to open it.
Let's test this out. Now if I approach the door, it tells me it's locked and does not open. But, after picking up the keys, it opens right up.
A key to door example is about as straightforward an example as it gets, but this setup can be used for much more elaborate inventory, long chain quests, and so on.
Examples
Here's a similar example. In this case, there's an inactive console that requires the player find a battery to activate. Once active, the batter appears in the machine, a red light turns green, and a platform begins moving across the level.
Third Person Camera Setup.
This setup spawns a bot when a trigger is used, but on top of that, if the bot is killed it triggers an event announcing that death. Of course, any event triggered can be used to do all kinds of crazy things beyond announcing it. Note: in the Actor Factory, set the Factory to UTActorFactoryAI. Force Deathmatch AI, give Default Inventory and Set the Pawn Class to UTPawn.
Console Commands can be called. Right Click > Action > Misc > Console Command. Besides ToggleHud, a couple fun ones are SetSpeed 1 (0.5 is a reasonable walk, 3 is super speed) and ChangeSize 1 (this can adjust the size of the player, 0.1 is as hilarious as 5).
Cinematic is great for a lot of things. Right click > Action > Toggle > Toggle Cinematic Mode.
Simple Kismet Flashlight
Bot Related:
Here's a fun idea of attaching a pathnode to the player and spawning a bot in front of yourself with a keybinding.
This example is a bot kill counter
Attaching an event to a bot that happens once the bot is killed
|
|