AnimationsClient
note
Roblox model path: Animations.Package.AnimationsClient
info
Any reference to "client animation tracks" is referring to animation ids found under rigType
of "Player" in the AnimationIds
module.
Types
initOptions
interface
initOptions {
AutoRegisterPlayer:
true
AutoLoadAllPlayerTracks:
false
TimeToLoadPrints:
true
EnableAutoCustomRBXAnimationIds:
false
AnimatedObjectsDebugMode:
false
}
Gets applied to Properties
.
path
type
path =
{
any
}
|
string
-- In a LocalScript
local Animations = require(game.ReplicatedStorage.Animations.Package.AnimationsClient)
-- These are all valid options for retrieving an animation track
local animationPath = "Jump" -- A single key (any type)
local animationPath = {"Dodge", Vector3.xAxis} -- An array path (values of any type)
local animationPath = "Climb.Right" -- A path seperated by "." (string)
local animationTrack = Animations:GetTrack(animationPath)
customRBXAnimationIds
interface
customRBXAnimationIds {
run:
number?
walk:
number?
jump:
number?
idle:
{
Animation1:
number?
,
Animation2:
number?
}
?
fall:
number?
swim:
number?
swimIdle:
number?
climb:
number?
}
A table of animation ids to replace the default roblox animation ids.
info
Roblox applies the "walk"
animation id for R6
characters and the "run"
animation id for R15
characters (instead of both).
humanoidRigTypeToCustomRBXAnimationIds
interface
humanoidRigTypeToCustomRBXAnimationIds {
[Enum.HumanoidRigType.R6]:
customRBXAnimationIds?
[Enum.HumanoidRigType.R15]:
customRBXAnimationIds?
}
A table mapping a Enum.HumanoidRigType
to its supported animation ids that will replace the default roblox animation ids.
Properties
DepsFolderPath
AnimationsClient.DepsFolderPath:
nil
Set the path to the dependencies folder if you have moved it from its original location inside of the root Animations
folder.
added in version 2.0.0-rc1
AutoRegisterPlayer
AnimationsClient.AutoRegisterPlayer:
true
If set to true, the client will automatically be registered on spawn. See Animations:Register()
for more info.
warning
Must have animation ids under rigType
of "Player" in the AnimationIds
module.
added in version 2.0.0-rc1
AutoLoadAllPlayerTracks
AnimationsClient.AutoLoadAllPlayerTracks:
false
If set to true, client animation tracks will be loaded each time the client spawns.
warning
Must have animation ids under rigType
of "Player" in the AnimationIds
module.
changed in version 2.0.0-rc1
Renamed: -> AutoLoadPlayerTracks
AutoLoadAllPlayerTracks
Will automatically register client as well if AutoRegisterPlayer
is not already set to true.
TimeToLoadPrints
AnimationsClient.TimeToLoadPrints:
true
If set to true, makes helpful prints about the time it takes to pre-load and load animations.
EnableAutoCustomRBXAnimationIds
AnimationsClient.EnableAutoCustomRBXAnimationIds:
false
If set to true, applies the AutoCustomRBXAnimationIds
module table to the client on spawn.
added in version 2.0.0-rc1
AnimatedObjectsDebugMode
AnimationsClient.AnimatedObjectsDebugMode:
false
If set to true, prints will be made to help debug attaching and detaching animated objects.
PreloadAsyncProgressed
AnimationsClient.PreloadAsyncProgressed:
RBXScriptSignal
Fires when ContentProvider:PreloadAsync()
finishes pre-loading one animation instance.
-- In a LocalScript
Animations.PreloadAsyncProgressed:Connect(function(n, total, loadedAnimInstance)
print("ContentProvider:PreloadAsync() finished pre-loading one:", n, total, loadedAnimInstance)
end)
added in version 2.0.0-rc1
Functions
Init
This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. YieldsInitializes AnimationsClient
.
Yields when...
- ...server has not initialized.
- ...animations are being pre-loaded with
ContentProvider:PreloadAsync()
(could take a while).
info
Should be called once before any other method.
GetAppliedProfileName
AnimationsClient:
GetAppliedProfileName
(
) →
string?
Returns the client's currently applied animation profile name or nil.
added in version 2.0.0
GetRigAppliedProfileName
Returns the rig
's currently applied animation profile name or nil.
added in version 2.0.0
AwaitPreloadAsyncFinished
This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. YieldsYields until ContentProvider:PreloadAsync()
finishes pre-loading all animation instances.
-- In a LocalScript
local loadedAnimInstances = Animations:AwaitPreloadAsyncFinished()
print("ContentProvider:PreloadAsync() finished pre-loading all:", loadedAnimInstances)
added in version 2.0.0-rc1
Register
AnimationsClient:
Register
(
) →
(
)
Registers the client's character so that methods using animation tracks can be called.
tip
Automatically gives the rig
(the client's character) an attribute "AnimationsRigType"
set to the rigType
(which is "Player" in this case).
added in version 2.0.0-rc1
RegisterRig
Registers the rig
so that rig methods using animation tracks can be called.
tip
Automatically gives the rig
an attribute "AnimationsRigType"
set to the rigType
.
added in version 2.0.0-rc1
AwaitRegistered
This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. YieldsAnimationsClient:
AwaitRegistered
(
) →
(
)
Yields until the client gets registered.
added in version 2.0.0-rc1
AwaitRigRegistered
This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. YieldsYields until the rig
gets registered.
added in version 2.0.0-rc1
IsRegistered
AnimationsClient:
IsRegistered
(
) →
boolean
Returns if the client is registered.
added in version 2.0.0-rc1
IsRigRegistered
Returns if the rig
is registered.
added in version 2.0.0-rc1
ApplyCustomRBXAnimationIds
This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. YieldsAnimationsClient:
ApplyCustomRBXAnimationIds
(
humanoidRigTypeToCustomRBXAnimationIds:
humanoidRigTypeToCustomRBXAnimationIds
) →
(
)
Applies the animation ids specified in the humanoidRigTypeToCustomRBXAnimationIds
table on the client's character.
Yields when...
- ...the client's character, humanoid, animator, or animate script aren't immediately available.
tip
See ApplyAnimationProfile()
for a more convenient way of overriding default roblox character animations.
-- In a LocalScript
local Animations = require(game.ReplicatedStorage.Animations.Package.AnimationsClient)
Animations:Init()
task.wait(5)
print("Applying r15 ninja jump & idle animations")
-- These animations will only work if your character is R15
Animations:ApplyCustomRBXAnimationIds({
[Enum.HumanoidRigType.R15] = {
jump = 656117878,
idle = {
Animation1 = 656117400,
Animation2 = 656118341
}
}
})
ApplyRigCustomRBXAnimationIds
This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. YieldsAnimationsClient:
ApplyRigCustomRBXAnimationIds
(
humanoidRigTypeToCustomRBXAnimationIds:
humanoidRigTypeToCustomRBXAnimationIds
) →
(
)
Applies the animation ids specified in the humanoidRigTypeToCustomRBXAnimationIds
table on the rig
.
Yields when...
- ...the
rig
's humanoid or animate script aren't immediately available.
warning
This function only works for R6/R15 NPCs that are local to the client or network-owned by the client and have a client-side "Animate"
script in their model.
tip
See ApplyRigAnimationProfile()
for a more convenient way of overriding default roblox character animations.
GetAnimationProfile
AnimationsClient:
GetAnimationProfile
(
animationProfileName:
string
) →
animationProfile
humanoidRigTypeToCustomRBXAnimationIds?
Returns the humanoidRigTypeToCustomRBXAnimationIds
table found in the profile module script Deps.<animationProfileName>
, or not if it doesn't exist.
ApplyAnimationProfile
This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. YieldsAnimationsClient:
ApplyAnimationProfile
(
animationProfileName:
string
) →
(
)
Applies the animation ids found in the animation profile on the client's character.
Yields when...
- ...the client's character, humanoid, animator, or animate script aren't immediately available.
info
For more information on setting up animation profiles check out animation profiles tutorial.
ApplyRigAnimationProfile
This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. YieldsApplies the animation ids found in the animation profile on the rig
.
Yields when...
- ...the
rig
's humanoid or animate script aren't immediately available.
warning
This function only works for R6/R15 NPCs that are local to the client or network-owned by the client and have a client-side "Animate"
script in their model.
info
For more information on setting up animation profiles check out animation profiles tutorial.
AwaitAllTracksLoaded
This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. YieldsAnimationsClient:
AwaitAllTracksLoaded
(
) →
(
)
Yields until the client has been registered and then until all animation tracks have loaded.
changed in version 2.0.0-rc1
Renamed: -> AwaitLoaded
AwaitAllTracksLoaded
-- In a LocalScript
-- [WARNING] For this to work you need animation ids under the rig type of "Player" in the 'AnimationIds' module
local Animations = require(game.ReplicatedStorage.Animations.Package.AnimationsClient)
Animations:Init({
AutoRegisterPlayer = true, -- Defaults to true (on the client)
AutoLoadAllPlayerTracks = true -- Defaults to false
})
Animations:AwaitAllTracksLoaded()
print("Animation tracks finished loading on the client!")
AwaitAllRigTracksLoaded
This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. YieldsYields until the rig
has been registered and then until all animation tracks have loaded.
changed in version 2.0.0-rc1
Renamed: -> AwaitRigTracksLoaded
AwaitAllRigTracksLoaded
AwaitTracksLoadedAt
This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. YieldsYields until the client has been registered and then until all animation tracks have loaded at path
.
added in version 2.0.0-rc1
AwaitRigTracksLoadedAt
This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. YieldsYields until the rig
has been registered and then until all animation tracks have loaded at path
.
added in version 2.0.0-rc1
AreAllTracksLoaded
AnimationsClient:
AreAllTracksLoaded
(
) →
boolean
Returns if the client has had all its animation tracks loaded.
changed in version 2.0.0-rc1
Renamed: -> AreTracksLoaded
AreAllTracksLoaded
AreAllRigTracksLoaded
Returns if the rig
has had all its animation tracks loaded.
changed in version 2.0.0-rc1
Renamed: -> AreRigTracksLoaded
AreAllRigTracksLoaded
AreTracksLoadedAt
Returns if the client has had its animation tracks loaded at path
.
added in version 2.0.0-rc1
AreRigTracksLoadedAt
Returns if the rig
has had its animation tracks loaded at path
.
added in version 2.0.0-rc1
LoadAllTracks
AnimationsClient:
LoadAllTracks
(
) →
(
)
Creates animation tracks from all animation ids in AnimationIds
for the client.
changed in version 2.0.0-rc1
Renamed: -> LoadTracks
LoadAllTracks
Now requires Animations:Register()
before usage unless Animations.AutoRegisterPlayer
is enabled.
LoadAllRigTracks
Creates animation tracks from all animation ids in AnimationIds
for the rig
.
changed in version 2.0.0-rc1
Renamed: -> LoadRigTracks
LoadAllRigTracks
Now requires Animations:RegisterRig()
before usage.
LoadTracksAt
Creates animation tracks from all animation ids in AnimationIds
for the client at path
.
added in version 2.0.0-rc1
LoadRigTracksAt
Creates animation tracks from all animation ids in AnimationIds
for the rig
at path
.
added in version 2.0.0-rc1
GetTrack
Returns a client animation track or nil.
GetRigTrack
Returns a rig
animation track or nil.
PlayTrack
Returns a playing client animation track.
PlayRigTrack
Returns a playing rig
animation track.
StopTrack
Returns a stopped client animation track.
StopRigTrack
Returns a stopped rig
animation track.
StopPlayingTracks
Returns the stopped client animation tracks.
changed in version 2.0.0-rc1
Renamed: -> StopAllTracks
StopPlayingTracks
StopRigPlayingTracks
Returns the stopped rig
animation tracks.
changed in version 2.0.0-rc1
Renamed: -> StopRigAllTracks
StopRigPlayingTracks
GetPlayingTracks
Returns the playing client animation tracks.
added in version 2.0.0-rc1
GetRigPlayingTracks
Returns the playing rig
animation tracks.
added in version 2.0.0-rc1
StopTracksOfPriority
AnimationsClient:
StopTracksOfPriority
(
animationPriority:
Enum.AnimationPriority
,
fadeTime:
number?
) →
{
AnimationTrack?
}
Returns the stopped client animation tracks.
StopRigTracksOfPriority
Returns the stopped rig
animation tracks.
GetTrackFromAlias
Returns a client animation track or nil.
GetRigTrackFromAlias
Returns a rig
animation track or nil.
PlayTrackFromAlias
AnimationsClient:
PlayTrackFromAlias
(
alias:
any
,
fadeTime:
number?
,
weight:
number?
,
speed:
number?
) →
AnimationTrack
Returns a playing client animation track.
PlayRigTrackFromAlias
Returns a playing rig
animation track.
StopTrackFromAlias
Returns a stopped client animation track.
StopRigTrackFromAlias
Returns a stopped rig
animation track.
SetTrackAlias
Sets an alias to be the equivalent of the path for a client animation track.
tip
You can use the alias as the last key in the path. Useful for a table of animations. Example:
-- In ReplicatedStorage.Animations.Deps.AnimationIds
local animationIds = {
Player = {
FistsCombat = {
-- Fists 3 hit combo
Combo = {
[1] = 1234567,
[2] = 1234567,
[3] = 1234567
},
-- Fists heavy attack
HeavyAttack = 1234567
},
SwordCombat = {
-- Sword 3 hit combo
Combo = {
[1] = 1234567,
[2] = 1234567,
[3] = 1234567
},
-- Sword heavy attack
HeavyAttack = 1234567
}
}
}
-- In a LocalScript
-- After the client's animation tracks are loaded...
local heavyAttackAlias = "HeavyAttack" -- We want this alias in order to call Animations:PlayTrackFromAlias(heavyAttackAlias) regardless what weapon is equipped
local currentEquippedWeapon
local function updateHeavyAttackAliasPath()
local alias = heavyAttackAlias
local path = currentEquippedWeapon .. "Combat"
Animations:SetTrackAlias(alias, path) -- Running this will search first "path.alias" and then search "path" if it didn't find "path.alias"
end
local function equipNewWeapon(weaponName)
currentEquippedWeapon = weaponName
updateHeavyAttackAliasPath()
end
equipNewWeapon("Fists")
Animations:PlayTrackFromAlias(heavyAttackAlias) -- Plays "FistsCombat.HeavyAttack" on the client's character
equipNewWeapon("Sword")
Animations:PlayTrackFromAlias(heavyAttackAlias) -- Plays "SwordCombat.HeavyAttack" on the client's character
SetRigTrackAlias
Sets an alias to be the equivalent of the path for a rig
animation track.
tip
Same tip for Animations:SetTrackAlias()
applies here.
RemoveTrackAlias
AnimationsClient:
RemoveTrackAlias
(
alias:
any
) →
(
)
Removes the alias for a client animation track.
RemoveRigTrackAlias
Removes the alias for a rig
animation track.
AttachAnimatedObject
BetaAttaches the animated object to the client's character.
note
This does not replicate to the server.
tip
Enable initOptions.AnimatedObjectsDebugMode
for detailed prints about animated objects.
info
For more information on setting up animated objects check out animated objects tutorial.
AttachRigAnimatedObject
BetaAttaches the animated object to the rig
.
note
This does not replicate to the server.
tip
Enable initOptions.AnimatedObjectsDebugMode
for detailed prints about animated objects.
info
For more information on setting up animated objects check out animated objects tutorial.
DetachAnimatedObject
BetaDetaches the animated object from the client's character.
note
This does not replicate to the server.
tip
Enable initOptions.AnimatedObjectsDebugMode
for detailed prints about animated objects.
info
For more information on setting up animated objects check out animated objects tutorial.
DetachRigAnimatedObject
BetaDetaches the animated object from the rig
.
note
This does not replicate to the server.
tip
Enable initOptions.AnimatedObjectsDebugMode
for detailed prints about animated objects.
info
For more information on setting up animated objects check out animated objects tutorial.