Skip to content
Docs
Make your game

Who sees what

Send chat, sounds, Menu parts, drawings, discs and walls to some players only, so a game can keep secrets.

Every message, sound, Menu or HUD part, drawing, disc and wall can name its audience: who receives it. The room checks the audience for each player before sending anything, so a player outside it never gets the data, not even hidden.

That is what lets a game keep secrets: a hint only one player sees, a whisper, footsteps only nearby players hear.

Audiences

AudienceWho receives it
none (the default)everyone, spectators and replays too
{ include: [player] }the listed players
{ exclude: [player] }everyone except them
{ role }players holding a role
{ near: 150, blockedBy: ["walls"] }players whose disc is within 150 units, with no wall of those collision groups in between
{ any: [ … ] }anyone in at least one of them

role, near and any also take exclude, and exclusions always win: { role: referee, exclude: [player] } is every referee but one.

near only works for things with a position the room knows: a sound with a source, a disc, a wall, or a drawing on one of them or at a fixed point.

Chat

src/main.ts

Sounds

src/main.ts

A sound plays when the player's screen reaches the moment it happened, never twice, and never for a player who joins later.

volume is a number from 0 to 1, or an expression each listener's screen works out on every frame while the sound plays. Fade a sound with distance like this:

src/main.ts

A volume that works out to nothing is silent.

A part outside its audience is left out, with everything inside it. With outside: Outside.Disabled it is shown but can't be used:

src/main.ts

The audience of a Menu or HUD part is checked again whenever a player's roles change.

Hidden discs and walls

A disc or wall with an audience reaches only the players in it. Everyone else never receives it: not its place, not its moves, not that it exists. A near audience is checked every tick, so things come and go as players move:

src/main.ts

Hidden things still push what players can see. A player sees only the push: the ball they can see changes direction, with no hint of what hit it. A player always knows the disc they control, and a drawing on a hidden disc or wall is hidden with it. setAudience changes an audience at any time.

Replays show everything: they are for after the match.

Drawings

A drawing with a near audience reaches the players near it, checked every tick. The room measures from the disc or wall the drawing follows, or from its fixed point:

src/main.ts

The room must know where the drawing is without asking screens. A drawing placed by an expression, such as one that follows the viewer's own disc with expr.me.position, can't be near: give it an anchor instead. A player standing at the edge keeps a drawing a little farther, so it doesn't flicker as they move.

Fading in

A near drawing arrives whole. To fade it in, give it an opacity that grows as the viewer comes closer, with the audience a little wider than where the fade starts:

src/main.ts

In Studio, set the visual's Opacity to Fade by distance, with From the visual's place, and its Shown to to Players near it.