Vixen
caa30e12
csharp
public sealed class PlaySoundTask

Plays a clip on the agent's own audio source, and optionally waits for it.

Read the guide page for this →

Remarks

doc 37 § Part 3's PlaySound. It writes the entity's own AudioSource and AudioClipRef rather than spawning anything: a sound a character makes belongs to the character, so it moves with it, stops when it dies and is spatialised by the AudioSpatial the character already carries.

⚠ The components must already be there, and the task fails rather than adding them. Adding a component is a structural change, and a tree step happens inside a chunk walk — every span the walk is holding would be invalidated under it. It is also the right default: a character that can make noises is authored with a source, and one that cannot is a bug worth seeing.

Fields and properties (1)

  • public static int StateSize

    How many bytes it needs.

Methods (4)

  • public PlaySoundTask(AudioClip? clip, bool wait = false, float gain = 1)

    Plays a clip on the agent's own audio source, and optionally waits for it.

  • public void Start(in AgentContext context, Span<byte> state)

    Begins. Called once before the first Tick, on a zeroed span.

  • public ActionStatus Tick(in AgentContext context, Span<byte> state, float delta)

    Advances it.

  • public void Abort(in AgentContext context, Span<byte> state)

Used by (2)

  • PlaySoundTestsVixen.Ai.Nodes.Tests
  • WorldNodesVixen.Ai.Nodes