Zone Chime
Before this: Reacting to the Game
A shop-door chime: a player who walks into an area hears a short sound. Only the player who walked in hears it, so a busy doorway stays quiet for everyone else.
Contents
You need
- a brick with an Attached Zone, covering the doorway or area
zone "Zone Ref" -> chip room
Code
const SOUND = $BrickOneShotAudioDescriptor/OBA_CashRegister_Ding // the chime
const PITCH = 1.0 // 1.0 is the sound as recorded; higher is higher
@left in room: zone
on ZoneEntered(zone = room) -> (character) {
character.PlayClientAudio(SOUND, pitch = PITCH)
}
Wire it
- Compile the chip and paste it in-game. Give a brick an Attached Zone that covers the doorway.
- Wire the Attached Zone’s Zone Ref to
room.
Check it in game
- Walk into the zone: you hear the chime once.
- Stand inside: nothing more plays.
- Walk out and back in: it chimes again.
- Ask a friend to watch from outside while you walk in: they hear nothing.
Change it
-
Pick another sound: type
$BrickOneShotAudioDescriptor/in the playground, and the editor lists the sounds.OBA_UI_Checkpoint_Acquire_Tune_Cuemakes a checkpoint chime. -
Play a lower note on the way out:
on ZoneLeft(zone = room) -> (character) { character.PlayClientAudio(SOUND, pitch = 0.7) } -
Let everyone nearby hear it: change
PlayClientAudiotoPlayAudioAt, which plays the sound at the player’s position for all players in range.
How it works
@left in room: zone takes the zone from the Attached Zone’s Zone Ref,
and on ZoneEntered(zone = room) runs each time a player walks in, naming
that player character (Reacting to the Game).
$BrickOneShotAudioDescriptor/... names one of the game’s sounds.
PlayClientAudio plays it for that one player only, with no direction or
distance: it sounds the same wherever they stand.