Return to the site

Underwhelming first Unreal tip

Here’s your first (rather underwhelming) Unreal tip. I plan to write up more detailed and complicated items when I’m out of crunch. Soon I hope!

Kismet is your friend. It can do amazing and wonderful things, especially with some of the more recent features like Sound Modes. One problem I’ve encountered when scripting audio behavior in Kismet is controlling when an event fires off. Sometimes you want to ensure that a sound event is only triggered once, but you want to attach it to something that fires off multiple times. An example might be firing off a music track the first time one of a handful of checkpoints are activated. However, as the player moves through your world, you don’t want to hit play on the music track again when they pass the NEXT check point. Or maybe you want to play a scary sound effect the third time a player tries to open a locked door.

Enter the Switch. This little object has a series of outputs (definable in the properties) that will fire off in sequence every time the input is hit. The secret is that, no matter how many outputs you define, the switch will continue moving sequentially down the list. The definition of outputs in the properties only controls how many outputs are VISIBLE in kismet, not how many actually exist (which is a large number I imagine). So if you want a sound to fire off once and only once, drop a switch in the path from your activating event and the input of your PlaySound/Play Music/whatever. Connect output 1 to the Play input, and any further attempts to trigger the event will do nothing because they’ll be firing off the other outputs, which aren’t visible or connected to anything.

To create the above example of firing off a sound the third time a player tries to open a locked door, do the same thing, only expose three outputs on the Switch and connect the third output to your PlaySound input. Only on the third time will the sound fire.

The same technique can be used to ensure that two (or more) different events occur before a sound event occurs. Just connect the output of the two required events to the input of the switch, connect the second output to your play sound and you’re in business. This is fantastic for hooking up a dialog line to play when the player has completed a handful of tasks.

More to come.

Leave a Reply