tensionKit.package
- .metadata67 B
- DreadDirector.component
- README.md11.6 KB
- api.module
- audio
- clips.module
- how-to-add-a-tension-director-with-heartbeat-and-creepy-music-to-a-horror-game.guide
- links.module
- outputs.module
- package.yaml1.5 KB
- readout.module
- styles.module
- tensionKitTests.testSuite
This package holds more than this page lists. See all of its files in its world.
README.md
tensionKit
Version 1.0.4.
Named tensionKit since 1.0.1 (it was published as dreadKit in 1.0.0). Search for either name.
A tension director for horror games. Every player gets their own dread level (0..1) that builds from what happens to them, silence, darkness (faster with the torch off), noises and gunfire, a threat closing in, near misses, low health, a dying battery, scares, and eases when they are lit, calm or in a safe room. Dread drives music, ambience, heartbeat, breathing and the screen/camera feel, and gates a scare director with pacing rules (minimum gap, breather after a big scare, an intensity budget that ramps up). Pacing, look and audio palette are each switched by one field. Every sound is original, generated with the engine's audio generation and shipped inside the package.
Install
Search ZeroMind for tensionKit (or install the package by guid), it needs nothing else and installing it brings no other kit. It works with these kits when the game links them (tensionKit.links; require("~horrorKit.api") links them all for you):
| Kit | What tensionKit uses it for |
|---|---|
| soundstage | dread-driven music (it defines dread_industrial, dread_deepsea, dread_organic, dread_synth sets) and ducking on peaks |
| aiKit | automatic light level at the player (AI.lightAt) and noises (AI.onNoise: gunfire, slams) |
| SecondWind | automatic health (HK.state(player).fraction) |
| juiceKit | camera sway, tremor and the peak jolt (juiceKit.shake) |
Link them yourself in a world that has those kits but not horrorKit:
local Links = require("~tensionKit.links")
-- hand over the kits your game has; a kit that is not installed is skipped
for _, name in { "soundstage.music", "soundstage.mix", "aiKit.api", "SecondWind.api", "juiceKit.shake" } do
if asset.tryResolve(name, "module") then Links.link(name, require("~" .. name)) end
end
Without them it still works: feed light, health and noises through the API.
First example
local Dread = require("~tensionKit.api")
-- once, for example in your scene entrypoint's onLoad:
Dread.start({ pacing = "slowBurn", look = "grain70s", palette = "deepSea" })
-- from your game:
Dread.stimulus("slam", 1, { at = vector.create(4, 1, 9) }) -- a door slammed there (weaker further away)
Dread.setThreat(12) -- the nearest monster is 12 m away (metres, or 0..1); call on change
Dread.setSafe(true) -- entering the safe room
Dread.on("peak", function() print("they're terrified") end)
-- a scare director asks before it fires:
if Dread.canScare(4) then
print("play your scare here")
Dread.scared(4) -- starts the gap + breather, raises dread, plays a stinger
end
Or place the DreadDirector component on any entity and pick the styles in the inspector. Press F3 in play to show the tuning readout.
Styles (one field each)
Pacing, Dread.setPacing(name) / DreadDirector pacing
| Name | Feel | Min gap | Breather / intensity | Budget start → ramp |
|---|---|---|---|---|
slowBurn | long quiet build from silence and darkness, few scares | 75 s | 14 s | 1, +1 every 150 s |
rollercoaster | tension swells in waves (70 s cycle); scare at the crest, then release | 35 s | 8 s | 2, +1 / 90 s |
relentless | never lets up: high floor (0.25), short gaps | 15 s | 3 s | 3, +1 / 45 s |
quietDread | atmosphere over shocks; capped at 0.72, small scares | 60 s | 12 s | 1, +1 / 240 s |
survivalClassic (default) | readable explore → threat → fight/flight → safe room rhythm | 45 s | 10 s | 2, +1 / 120 s |
arcade | fast rise and fall, frequent scares, short sessions | 12 s | 2.5 s | 3, +1 / 30 s |
Screen feel, Dread.setLook(name) / look
Every look scales with dread: vignette closing in, film grain, desaturation, colour tint, chromatic aberration, a slight FOV squeeze and a slow sway/tremor.
| Name | Look |
|---|---|
clean (default) | modern and restrained; soft vignette and desaturation only when it matters |
grain70s | warm faded 16 mm stock, heavy grain, amber tint that sours |
vhs | found footage: strong colour bleed (aberration), noisy grain, cold cast |
coldMonitor | clinical blue-cyan, crisp contrast; dread drains to steel monochrome |
sickly | fluorescent-rot green cast, heavy vignette, slow sway |
bleachBypass | silvery, crushed, high contrast, little colour |
Audio palette, Dread.setPalette(name) / palette
| Name | Drone, one-shots and music |
|---|---|
industrial (default) | machinery hum, pipe knocks, metal groans; distorted cello and metal percussion |
deepSea | hull pressure, sonar, drips; low brass and bowed metal |
organic | breathing textures, whispers, creaks; folk-horror strings and choir |
synth | detuned analog pads, cold arpeggios (80s horror score) |
classic | soundstage's own horror set over the industrial drone |
Each palette's music has three generated tracks: low (uneasy), high (building dread) and chase (terror), mapped to soundstage states explore (low/high) and action (high/chase).
Outputs, Dread.setOutputs{ ... }
music, ambience, heartbeat, breathing, screen, camera, stingers, each on by default, each switchable alone (also as DreadDirector fields).
How dread moves
- Builds: darkness below ~0.35 light (×1.6 with the torch off, ×0.6 with it on), silence after the pacing's
silenceDelay, threat (pulls up and holds a floor at 0.85 × threat), health under 50 % (and a floor), battery under 25 % in the dark, every stimulus at once. - Eases: when there is no threat and nothing happened for 4 s, at the pacing's decay rate, up to 3× faster in light; slower while hiding. Safe rooms drain fast and block building.
- Bands: calm < 0.2 ≤ uneasy < 0.4 ≤ tense < 0.6 ≤ terror < 0.8 ≤ panic.
peakfires when dread crosses 0.85 (re-arms below 0.65): tinnitus, a duck of music and ambience, a camera jolt. - Music is silent while calm with pacings that say so (
slowBurn,rollercoaster,survivalClassic) and in safe rooms;explorebelow 0.72,actionabove (or when the threat is above 0.6).
API (require("~tensionKit.api"))
| Call | Does |
|---|---|
start(opts?) / configure(opts) | { pacing, look, palette, outputs = {...}, autoSense, debugKey }; start also makes sure the director runs |
stimulus(kind, amount?, opts?) | kinds: noise, gunshot, slam, scream, nearMiss, scare, sighting, hurt, darkness, battery, torchFail, custom, and negative calm, relief. opts.at + opts.radius (25 m) fade it with distance, opts.weight overrides |
setThreat(v, opts?) | metres (> 1: ≤ 3 m full, ≥ 25 m none) or 0..1; held 5 s (opts.hold) then fades |
setSafe(on) / setHiding(on) | safe room: no build, fast drain, no scares, music quiet. Hiding: breathing and heartbeat audible, dread holds |
setTorch(on), setBattery(0..1), setHealth(0..1), setLight(v or nil) | inputs when the soft links are absent or you want to override |
get(), band(), state() | level, band, everything (threat, light, silence, budget, recent stimuli, …) |
canScare(i), scared(i, opts?), suggestScare() | the pacing gate; opts.stinger = false skips the stinger |
setPacing, setLook, setPalette, setOutputs, styles(), config() | the switches |
set(v), reset() | force a level (cutscene, checkpoint), back to calm |
debug(on?), isDebug() | the readout (also the debug key, F3) |
on(event, fn) -> disconnect | events below |
require("~tensionKit.outputs").report() reads every voice's volume and mixer state, the post-process passes, music and FOV, useful in tests. outputs.sting("soft"|"swell"|"hard") plays a stinger by hand.
Events
| Event | Payload | When |
|---|---|---|
level | { value, band } | band changes, and every 0.05 of movement |
band | { band, previous, value } | band changes |
peak | { value } | dread crosses 0.85 |
safe | { on } | setSafe changes |
stimulus | { kind, amount, value } | each stimulus |
scare | { intensity } | scared() |
Wiring with the other horror kits (horrorKit does this)
In a world that also has flashlightKit, stalkerKit and scaresKit (horrorKit installs them all and runs this wiring for you):
local Dread = require("~tensionKit.api")
local me = multiplayer.getPeerId()
-- each block wires one kit, and only runs when that kit is installed
if asset.tryResolve("flashlightKit.api", "module") then
local Torch = require("~flashlightKit.api")
Torch.on("toggled", function(e) if e.player == me then Dread.setTorch(e.on) end end)
Torch.on("batteryLow", function(e) Dread.setBattery(e.charge) end)
Torch.on("failed", function() Dread.stimulus("torchFail", 1) end)
end
if asset.tryResolve("stalkerKit.api", "module") then
local Stalker = require("~stalkerKit.api")
Stalker.on("state", function(e) if e.state == "chase" then Dread.stimulus("sighting", 1) end end)
end
if asset.tryResolve("scaresKit.api", "module") then
local Scares = require("~scaresKit.api")
Scares.setGate(function(i) return Dread.canScare(i) end); Scares.on("scare", function(s) Dread.scared(s.intensity) end)
end
Multiplayer
Dread is per player and local: every engine runs its own director for its own player and nothing is sent over the network. Each player hears their own heartbeat and breathing, sees their own screen feel, and tensionKit switches soundstage music to shared = false while it drives it, so two players in different rooms hear different music. Stimuli with at fade with each player's own distance. Tested with the sub-client and the user's client in one play session.
Performance
One small update per frame: a handful of arithmetic, the light probe and health read every 0.4 s, music decisions every 0.5 s, post-process properties written only when they change by more than 0.002, the readout rebuilt at 5 Hz only while shown. Uses the engine's built-in vignette, chromatic aberration, colour correction and lensFx film grain, no custom shaders, so it runs on web and tablets.
Known limits
- The screen feel uses the client's whole post-process chain, so it also grades anything else drawn on the scene layer (not the UI).
- FOV squeeze writes the active camera's
fov; a controller that rewrites fov every frame wins (tensionKit then rebases on its value). - Sway and tremor need juiceKit; without it only the FOV squeeze moves the camera.
- Without aiKit, light reads 1 (lit) unless you call
setLight. - soundstage music is switched to local-only while tensionKit drives it; turn the
musicoutput off if your game wants shared music.
1.0.1
Renamed from dreadKit. The screen grade and grain never lift pure black. Test suite renamed tensionKitTests.
1.0.2
Installs alone: soundstage, aiKit, SecondWind and juiceKit are no longer required by name (a published literal require made each a dependency of every install). The game links them through tensionKit.links; require("~horrorKit.api") does it for you.
1.0.3
README: the first example runs as written (no placeholder door, distance or scare function); the wiring example requires the kits it uses.
1.0.4
Leaving play is quiet: the camera feel only restores the field of view while the camera still exists. The first and third README examples link each optional kit only when it is installed, so both run as pasted into a world with only tensionKit installed.