Skip to main content

Audiences

Many functions take an audience parameter to determine who can see or hear the effect of the function. Examples include PolygonSprite, Transmission, and Hear, but there are many more. Limiting effects to particular players allows you to create abilities where one player vanishes from the sight of their enemies, or to create user interface sections which only one player can see and control.

The audience parameter can take either an Audience constant, a player or team Entity, or a combination of Alliance Flags.

Audience constants

The audience parameter can be set to one of the following values:

  • Audience:All means that all players and spectators will see or hear the effect.
  • Audience:Players means only players, not spectators, will see or hear the effect.
  • Audience:Spectators means only spectators, not players, will see or hear the effect.
  • Audience:None means no one will see or hear the effect.
pub fn Bomb([owner]) {
Spawn projectile {
// ...
ImageSprite(@nuclearLaunchDetected.svg, radius=5, audience=Audience:Spectators)
}
}

See also the list of Audience constants in the reference section.

Player or team

You can also set the audience parameter to a specific player or team entity to limit its visibility to just that player or team.

pub fn Bomb([owner]) {
Spawn projectile {
// ...
ImageSprite(@danger.svg, radius=5, audience=owner.Team)
}
}

You can get a player or team entity from a function like SpawnEachPlayer, Owner or Team.

Alliance flags

Additionally, you can set the audience parameter to a combination of Alliance flags. For example, Alliance:Enemy would only show the effect to enemies, whereas Alliance:Self | Alliance:Ally would show the effect to the owner and their allies. Don't forget to add Alliance:Neutral (for example, Alliance:Enemy | Alliance:Neutral) if you want spectators to see the effect as well.

warning

When using Alliance:Self, Alliance:Ally or Alliance:Enemy as your audience, make sure you also pass in the owner parameter either explicitly or implicitly pass in through context. Otherwise, no one will see the effect.

See Alliance flags for a more thorough description of the different alliance flags.

info

If you are using audience = Alliance:Self | Alliance:Ally, consider using audience = owner.Team directly instead. Alliance flags must be re-checked each frame because teams can change, whereas owner.Team is calculated once when the function is called, so it is more efficient to use owner.Team if you can.

Default audience

If you don't specify audience, the default depends on the function. Most functions default to Audience:All, but some functions default to showing the effect only to the owner. Easel tries to choose a sensible default, depending on the function and the context in which it is used.

The user interface sections, such as Transmission and Content, both default to only showing the effect to the owner. This is because if you are creating these sections in the context of an owner, it is expected that you only want the owner to see them.

However, functions like PolygonSprite or Hear default to Audience:All, as most of the time you would want everyone to see or hear their effect.