Skip to main content
Version: Current

Animation Actions

os.startFormAnimation(botOrBots: (string | Bot | (string | Bot)[]), nameOrIndex: (string | number), options?: StartFormAnimationOptions): Promise<void>

Starts the given animation on the given bot or list of bots using the given options. Returns a promise that resolves once the animation(s) have been started.

Triggers the @onFormAnimationStarted and @onAnyFormAnimationStarted listeners once the animation has started.

The first parameter is a (string | Bot | (string | Bot)[]) and is the bot or list of bots that the animation should be started on.

The second parameter is a (string | number) and is the name of the animation that should be started. Additionally, it can be the index number of the animation that should be played.

The third parameter is optional and is a StartFormAnimationOptions and is the options that should be used to play the animation.

Examples

Start the "Run" animation on this bot
await os.startFormAnimation(thisBot, "Run");
Start the "Run" animation on every bot in the home dimension
await os.startFormAnimation(getBots(inDimension("home")), "Run");
Start an animation that loops 5 times
await os.startFormAnimation(thisBot, "Run", {
loop: {
mode: 'repeat',
count: 5
}
});
Start an animation which starts playing 5 seconds in the future
await os.startFormAnimation(thisBot, "Run", {
startTime: os.localTime + 5000
});
Start an animation which plays at half its normal speed
await os.startFormAnimation(thisBot, "Run", {
timeScale: 0.5
});

os.stopFormAnimation(botOrBots: (string | Bot | (string | Bot)[]), options?: StopFormAnimationOptions): Promise<void>

Stops the animations that are running on the given bot or list of bots using the given options. Returns a promise that resolves once the animations have been stopped.

This function only works for animations that have been started by os.startFormAnimation(botOrBots, nameOrIndex, options).

Triggers the @onFormAnimationStopped and @onAnyFormAnimationStopped listeners once the animation has stopped.

The first parameter is a (string | Bot | (string | Bot)[]) and is the bot or list of bots whose animations should be stopped.

The second parameter is optional and is a StopFormAnimationOptions and is the options that should be used for stopping the animations.

Examples

Stop the animations on this bot
await os.stopFormAnimation(thisBot);
Slowly stop the animations on this bot
await os.stopFormAnimation(thisBot, {
fadeDuration: 1000 // Take 1 second to stop the animation
});
Stop the current animation 5 seconds in the future
await os.stopFormAnimation(thisBot, {
stopTime: os.localTime + 5000
});

os.listFormAnimations(botOrAddress: (string | Bot)): Promise<FormAnimationData[]>

Retrieves the list of animations that are available on the given bot or GLTF mesh address. Returns a promise that resolves with the list of available animations.

The first parameter is a (string | Bot) and is the bot or address that the animation list should be retrieved from

Examples

Get the list of animations on this bot
const animations = await os.listFormAnimations(thisBot);
Get the list of animations for a specific address
const animations = await os.listFormAnimations('https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/Fox/glTF/Fox.gltf');

os.bufferFormAddressGLTF(address: string): Promise<void>

Pre-caches the given GLTF mesh address so that it will load instantly when used on a bot later. Returns a promise that resolves once the address has been cached.

The first parameter is a string and is the address that should be cached.

Examples

Buffer a specific GLTF
await os.bufferFormAddressGLTF('https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/Fox/glTF/Fox.gltf');
os.toast("Buffered!");