Caffeine

Animation

Reference Rendering Last updated: Lua 7 · Dryad 0

Clip, state-machine, skinned-mesh and sprite-sheet animation control.

All namespaces

Namespace: caffeine.animation

playClip#

Lua: caffeine.animation.playClip

text
playClip(entity, path) -> boolean

Plays an animation clip on the entity.

ParametersTypeDescription
entitynumberEntity id.
pathstringClip asset path.

Returns: boolean. true on success.

Example

lua
caffeine.animation.playClip(e, 'clips/run.anim')

playSkinnedClip#

Lua: caffeine.animation.playSkinnedClip

text
playSkinnedClip(entity, meshPath, clipIndex) -> boolean

Plays a clip of a skinned mesh by index.

ParametersTypeDescription
entitynumberEntity id.
meshPathstringSkinned mesh path.
clipIndexnumberIndex of the clip in the mesh.

Returns: boolean. true on success.

Example

lua
caffeine.animation.playSkinnedClip(e, 'models/hero.glb', 0)

playState#

Lua: caffeine.animation.playState

text
playState(entity, state) -> boolean

Switches the animator to a named state.

ParametersTypeDescription
entitynumberEntity id.
statestringState name.

Returns: boolean. true on success.

Example

lua
caffeine.animation.playState(e, 'Idle')

setBool#

Lua: caffeine.animation.setBool

text
setBool(entity, name, value) -> boolean

Sets a boolean animator parameter.

ParametersTypeDescription
entitynumberEntity id.
namestringParameter name.
valuebooleanNew value.

Returns: boolean. true on success.

Example

lua
caffeine.animation.setBool(e, 'grounded', true)

setFloat#

Lua: caffeine.animation.setFloat

text
setFloat(entity, name, value) -> boolean

Sets a float animator parameter.

ParametersTypeDescription
entitynumberEntity id.
namestringParameter name.
valuenumberNew value.

Returns: boolean. true on success.

Example

lua
caffeine.animation.setFloat(e, 'speed', 3.5)

setTrigger#

Lua: caffeine.animation.setTrigger

text
setTrigger(entity, name) -> boolean

Fires an animator trigger.

ParametersTypeDescription
entitynumberEntity id.
namestringTrigger name.

Returns: boolean. true on success.

Example

lua
caffeine.animation.setTrigger(e, 'jump')

setSpriteSheet#

Lua: caffeine.animation.setSpriteSheet

text
setSpriteSheet(entity, columns, rows, frameCount) -> boolean

Configures sprite-sheet animation on the entity.

ParametersTypeDescription
entitynumberEntity id.
columnsnumberColumns in the sheet.
rowsnumberRows in the sheet.
frameCountnumberTotal number of frames.

Returns: boolean. true on success.

Example

lua
caffeine.animation.setSpriteSheet(e, 4, 4, 16)