Animation
Methods for specific Blockbench animations
For all examples on this page assume
local myAnim = animations.myModel.myAnimation
(and that this is a valid animation path)
For an explanation on indexing animations, see the Animations Tutorial
Play/Stop
play()
Initializes the animation
Resume the animation if it was paused
play()
Returns:
Type | Description |
---|---|
Animation | Returns the given animation for chaining |
Example:
myAnim:play()
stop()
Stop the animation
stop()
Returns:
Type | Description |
---|---|
Animation | Returns the given animation for chaining |
Example:
myAnim:stop()
pause()
Pause the animation's playback
pause()
Returns:
Type | Description |
---|---|
Animation | Returns the given animation for chaining |
Example:
myAnim:pause()
restart()
Restarts the animation
Plays the animation if it was stopped
This behavior can also be reproduced by stopping then playing the animation
restart()
Returns:
Type | Description |
---|---|
Animation | Returns the given animation for chaining |
Example:
myAnim:restart()
setPlaying()
Aliases: playing()
A function that merges "play" and "stop" together
Takes a boolean parameter, where if true, the animation will play, and when false, the animation will stop
- Overload 1
- Overload 2
Example (Overload 2):
-- This example would be in a function like a tick event
local crouching = player:getPose() == "CROUCHING"
myAnim:setPlaying(crouching)
isPlaying()
Checks if the animation is playing
isPlaying()
Returns:
Type | Description |
---|---|
Boolean | Returns true if the animation is playing, and false if it isn't |
Example:
myAnim:isPlaying()
isStopped()
Checks if the animation is stopped
isStopped()
Returns:
Type | Description |
---|---|
Boolean | Returns true if the animation is stopped, and false if it isn't |
Example:
myAnim:isStopped()
isPaused()
Checks if the animation is paused
isPaused()
Returns:
Type | Description |
---|---|
Boolean | Returns true if the animation is paused, and false if it isn't |
Example:
myAnim:isPaused()
getPlayState()
Get the animation's playback state
getPlayState()
Returns:
Type | Description |
---|---|
String | Returns the PlayState |
Example:
myAnim:getPlayState()
Timing
setSpeed()
Aliases: speed()
Sets the animation's playback speed
Negative numbers can be used for an inverted animation
Default speed is 1, 2 is twice the speed, and 0.5 is half the speed
setSpeed(speed)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
speed | Number | Sets the animation's speed | 1 |
Returns:
Type | Description |
---|---|
Animation | Returns the given animation for chaining |
Example:
myAnim:setSpeed(2)
getSpeed()
Gets the animation's speed
getSpeed()
Returns:
Type | Description |
---|---|
Number | The animation's speed as a number |
Example:
myAnim:getSpeed()
setLength()
Aliases: length()
Set the animation's length, in seconds
setLength(length)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
length | Number | The length of time, in seconds | 0 |
Returns:
Type | Description |
---|---|
Animation | Returns the given animation for chaining |
Example:
myAnim:setLength(2)
getLength()
Gets the animation's length, in seconds
getLength()
Returns:
Type | Description |
---|---|
Number | Returns the animation's length, in seconds |
Example:
myAnim:getLength()
setPriority()
Aliases: priority()
Sets the animation's priority
Instead of blending, low priority animations are overridden by high priority ones
The default priority of animations is 0
setPriority(priority)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
priority | Integer | The priority of the animation, as a whole number | 0 |
Returns:
Type | Description |
---|---|
Animation | Returns the given animation for chaining |
Example:
myAnim:setPriority(1)
getPriority()
Gets the animation's priority
getPriority()
Returns:
Type | Description |
---|---|
Integer | Returns the animation's priority number |
Example:
myAnim:getPriority()
setTime()
Aliases: time()
Sets the animation's playback current time, in seconds
setTime(time)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
time | Number | The time to set the animation to, in seconds | 0 |
Returns:
Type | Description |
---|---|
Animation | Returns the given animation for chaining |
Example:
myAnim:setTime(1.5)
getTime()
Get the animation's playback current time, in seconds
getTime()
Returns:
Type | Description |
---|---|
Number | Returns the playback time of the animation |
Example:
myAnim:getTime()
setOffset()
Aliases: offset()
Sets how much time to skip for the animation, in seconds
The time is skipped on every loop
setOffset(offset)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
offset | Number | Time in seconds to skip for each loop | 0 |
Returns:
Type | Description |
---|---|
Animation | Returns the given animation for chaining |
Example:
myAnim:setOffset(1.75)
getOffset()
Gets the animation's offset time, in seconds
getOffset()
Returns:
Type | Description |
---|---|
Number | The time that is skipped every loop, in seconds |
Example:
myAnim:getOffset()
setLoop()
Aliases: loop()
Sets the animation's loop mode
setLoop(loop)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
loop | String | Sets the LoopMode | Required |
Returns:
Type | Description |
---|---|
Animation | Returns the given animation for chaining |
Example:
myAnim:setLoop("ONCE")
getLoop()
Gets the animation's loop mode
getLoop()
Returns:
Type | Description |
---|---|
String | Returns the LoopMode |
Example:
myAnim:getLoop()
setBlend()
Aliases: blend()
Sets the animation's keyframe blend factor, which is the strength of the animation
setBlend(blend)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
blend | Number | Strength of the blend factor between 0 and 1 | 1 |
Returns:
Type | Description |
---|---|
Animation | Returns the given animation for chaining |
Example:
myAnim:setBlend(.5)
getBlend()
Gets the animation's keyframe blend factor, which is the strength of the animation
getBlend()
Returns:
Type | Description |
---|---|
Number | Gets the strength of the blend factor between 0 and 1 |
Example:
myAnim:getBlend()
setStartDelay()
Aliases: startDelay()
Set how much time to wait before this animation is initialized, in seconds
Note that while it is waiting, the animation is considered being played
setStartDelay(delay)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
delay | Number | The time in seconds to set the delay to | 0 |
Returns:
Type | Description |
---|---|
Animation | Returns the given animation for chaining |
Example:
myAnim:setStartDelay(1)
getStartDelay()
Gets the animation's start delay, in seconds
getStartDelay()
Returns:
Type | Description |
---|---|
Number | The time in seconds that it's being delayed |
Example:
myAnim:getStartDelay()
setLoopDelay()
Aliases: loopDelay()
Set how much time to wait in between the loops of this animation, in seconds
setLoopDelay(delay)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
delay | Number | The time in seconds to set the delay to | 0 |
Returns:
Type | Description |
---|---|
Animation | Returns the given animation for chaining |
Example:
myAnim:setLoopDelay(1)
getLoopDelay()
Gets the animation's loop delay, in seconds
getLoopDelay()
Returns:
Type | Description |
---|---|
Number | The time in seconds that it's being delayed |
Example:
myAnim:getLoopDelay()
Overriding
setOverride()
Aliases: override()
Set if this animation should override all of its parts vanilla transforms
Equivalent of calling "overrideRot", "overridePos" and "overrideScale" altogether
setOverride(override)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
override | Boolean | True or false if it should or shouldn't override all transformations | false |
Returns:
Type | Description |
---|---|
Animation | Returns the given animation for chaining |
Example:
myAnim:setOverride(true)
setOverrideRot()
Aliases: overrideRot()
Set if this animation should override its parts vanilla rotation
setOverrideRot(override)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
override | Boolean | True or false if it should or shouldn't override rotation | false |
Returns:
Type | Description |
---|---|
Animation | Returns the given animation for chaining |
Example:
myAnim:setOverrideRot(true)
getOverrideRot()
Gets if this animation should override its parts vanilla rotation
getOverrideRot()
Returns:
Type | Description |
---|---|
Boolean | Returns if it should be overriding rotation |
Example:
myAnim:getOverrideRot()
setOverridePos()
Aliases: overridePos()
Set if this animation should override its parts vanilla position
setOverridePos(override)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
override | Boolean | True or false if it should or shouldn't override position | false |
Returns:
Type | Description |
---|---|
Animation | Returns the given animation for chaining |
Example:
myAnim:setOverridePos(true)
getOverridePos()
Gets if this animation should override its parts vanilla position
getOverridePos()
Returns:
Type | Description |
---|---|
Boolean | Returns if it should be overriding position |
Example:
myAnim:getOverridePos()
setOverrideScale()
Aliases: overrideScale()
Set if this animation should override its parts vanilla scale
setOverrideScale(override)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
override | Boolean | True or false if it should or shouldn't override scale | false |
Returns:
Type | Description |
---|---|
Animation | Returns the given animation for chaining |
Example:
myAnim:setOverrideScale(true)
getOverrideScale()
Gets if this animation should override its parts vanilla scale
getOverrideScale()
Returns:
Type | Description |
---|---|
Boolean | Returns if it should be overriding scale |
Example:
myAnim:getOverrideScale()
Misc
getName()
Returns this animation's name
getName()
Returns:
Type | Description |
---|---|
String | Returns the animation's name |
Example:
myAnim:getName()
newCode()
Adds a string to run in a determinant time
If there's already code to run at that time, it is overwritten
newCode(time, code)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
time | Number | The time in seconds to add the code to | 0 |
code | String | The code to run at that time | Required |
Returns:
Type | Description |
---|---|
Animation | Returns the given animation for chaining |
Example:
myAnim:newCode(0.5, "log('Hello World')")
Fields
name
This animation's name
Example:
myAnim.name