Agent

Description

Supported Script Types: Assignment Client Scripts

The Agent API enables an assignment client to emulate an avatar. Setting isAvatar = true connects the assignment client to the avatar and audio mixers, and enables the Avatar API to be used.

Properties

Name Type Summary
isAvatar boolean

true if the assignment client script is emulating an avatar, otherwise false.

isPlayingAvatarSound boolean

true if the script has a sound to play, otherwise false. Sounds are played when isAvatar is true, from the position and with the orientation of the scripted avatar's head. Read-only.

isListeningToAudioStream boolean

true if the agent is "listening" to the audio stream from the domain, otherwise false.

isNoiseGateEnabled boolean

true if the noise gate is enabled, otherwise false. When enabled, the input audio stream is blocked (fully attenuated) if it falls below an adaptive threshold.

lastReceivedAudioLoudness number

The current loudness of the audio input. Nominal range [0.0 (no sound) – 1.0 (the onset of clipping)]. Read-only.

sessionUUID Uuid

The unique ID associated with the agent's current session in the domain. Read-only.

Methods

Name Return Value Summary
isAvatar boolean

Checks whether the script is emulating an avatar.

playAvatarSound None

Plays a sound from the position and with the orientation of the emulated avatar's head. No sound is played unless isAvatar == true.

setIsAvatar None

Sets whether the script should emulate an avatar.

Method Details

(static) isAvatar( ) → {boolean}
Returns: true if the script is emulating an avatar, otherwise false.

Checks whether the script is emulating an avatar.

Example

Check whether the agent is emulating an avatar.

(function () {
    print("Agent is avatar: " + Agent.isAvatar());
    print("Agent is avatar: " + Agent.isAvatar); // Same result.
}());
(static) playAvatarSound( avatarSound )

Plays a sound from the position and with the orientation of the emulated avatar's head. No sound is played unless isAvatar == true.

Parameters

Name Type Description
avatarSound SoundObject

The sound played.

Example

Play a sound from an emulated avatar.

(function () {
    Agent.isAvatar = true;
    var sound = SoundCache.getSound(Script.resourcesPath() + "sounds/sample.wav");
    Script.setTimeout(function () { // Give the sound time to load.
        Agent.playAvatarSound(sound);
    }, 1000);
}());
     
(static) setIsAvatar( isAvatar )

Sets whether the script should emulate an avatar.

Parameters

Name Type Description
isAvatar boolean

true if the script emulates an avatar, otherwise false.

Example

Make an assignment client script emulate an avatar.

(function () {
    Agent.setIsAvatar(true);
    Avatar.displayName = "AC avatar";
    print("Position: " + JSON.stringify(Avatar.position));  // 0, 0, 0
}());