AnimationsServer
note
Roblox model path: Animations.Package.AnimationsServer
Types
initOptions
interface
initOptions {
AutoLoadAllPlayerTracks:
false
AutoRegisterPlayers:
true
TimeToLoadPrints:
false
EnableAutoCustomRBXAnimationIds:
false
AnimatedObjectsDebugMode:
false
}
Gets applied to Properties
.
path
type
path =
{
any
}
|
string
-- In a ServerScript
local Animations = require(game.ReplicatedStorage.Animations.Package.AnimationsServer)
-- 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(player, 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 humanoid rig type to its supported animation ids that will replace the default roblox animation ids.
Properties
DepsFolderPath
AnimationsServer.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
AutoRegisterPlayers
AnimationsServer.AutoRegisterPlayers:
true
If set to true, player characters 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
AnimationsServer.AutoLoadAllPlayerTracks:
false
If set to true, all player animation tracks will be loaded for each player character on spawn.
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 players as well if AutoRegisterPlayers
is not already set to true.
TimeToLoadPrints
AnimationsServer.TimeToLoadPrints:
true
If set to true, makes helpful prints about the time it takes to pre-load and load animations.
changed in version 2.0.0-rc1
Defaults to true
.
EnableAutoCustomRBXAnimationIds
AnimationsServer.EnableAutoCustomRBXAnimationIds:
false
If set to true, applies the AutoCustomRBXAnimationIds
module table to each player character on spawn.
AnimatedObjectsDebugMode
AnimationsServer.AnimatedObjectsDebugMode:
false
If set to true, prints will be made to help debug attaching and detaching animated objects.
PreloadAsyncProgressed
AnimationsServer.PreloadAsyncProgressed:
RBXScriptSignal
Fires when ContentProvider:PreloadAsync()
finishes pre-loading one animation instance.
-- In a ServerScript
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 AnimationsServer
. Clients are unable to initialize until this gets called.
Yields when...
- ...animations are being pre-loaded with
ContentProvider:PreloadAsync()
(could take a while).
info
Should be called once before any other method.
GetAppliedProfileName
Returns the player_or_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 ServerScript
local loadedAnimInstances = Animations:AwaitPreloadAsyncFinished()
print("ContentProvider:PreloadAsync() finished pre-loading all:", loadedAnimInstances)
added in version 2.0.0-rc1
Register
Registers the player's character/rig so that methods using animation tracks can be called.
tip
Automatically gives the character/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. YieldsYields until the player_or_rig
gets registered.
added in version 2.0.0-rc1
IsRegistered
Returns if the player_or_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. YieldsAnimationsServer:
ApplyCustomRBXAnimationIds
(
humanoidRigTypeToCustomRBXAnimationIds:
humanoidRigTypeToCustomRBXAnimationIds
) →
(
)
Applies the animation ids specified in the humanoidRigTypeToCustomRBXAnimationIds
table on the player_or_rig
.
Yields when...
- ...the player's character, player or rig's humanoid, player's animator, or player or rig's animate script aren't immediately available.
warning
This function only works for players and R6/R15 NPCs that have an "Animate"
script in their model.
tip
See ApplyAnimationProfile()
for a more convenient way of overriding default roblox character animations.
-- In a ServerScript
local Animations = require(game.ReplicatedStorage.Animations.Package.AnimationsServer)
Animations:Init()
task.wait(5)
print("Applying r15 ninja jump & idle animations")
-- These animations will only work if your character is R15
Animations:ApplyCustomRBXAnimationIds(game.Players.YourName, {
[Enum.HumanoidRigType.R15] = {
jump = 656117878,
idle = {
Animation1 = 656117400,
Animation2 = 656118341
}
}
})
GetAnimationProfile
AnimationsServer:
GetAnimationProfile
(
animationProfileName:
string
) →
animationProfile
humanoidRigTypeToCustomRBXAnimationIds?
Returns the humanoidRigTypeToCustomRBXAnimationIds
table found in the profile module 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. YieldsAnimationsServer:
ApplyAnimationProfile
(
) →
(
)
Applies the animation ids found in the animation profile on the player_or_rig
.
Yields when...
- ...the player's character, player or rig's humanoid, player's animator, or player or rig's animate script aren't immediately available.
warning
This function only works for players and R6/R15 NPCs that have an "Animate"
script in their model.
info
For more information on setting up animated objects 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. YieldsYields until all the player_or_rig
's animation tracks have loaded.
changed in version 2.0.0-rc1
Renamed: -> AwaitLoaded
AwaitAllTracksLoaded
-- In a ServerScript
-- [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.AnimationsServer)
Animations:Init({
AutoRegisterPlayers = true, -- Defaults to false (on the server)
AutoLoadAllPlayerTracks = true -- Defaults to false
})
local player = game.Players:WaitForChild("MyName")
Animations:AwaitAllTracksLoaded(player)
print("Animation tracks finished loading on the server!")
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 player_or_rig
's animation tracks have loaded at path
.
added in version 2.0.0-rc1
AreAllTracksLoaded
Returns if the player_or_rig
has had all its animation tracks loaded.
changed in version 2.0.0-rc1
Renamed: -> AreTracksLoaded
AreAllTracksLoaded
AreTracksLoadedAt
Returns if the player_or_rig
has had its animation tracks loaded at path
.
added in version 2.0.0-rc1
LoadAllTracks
Creates animation tracks from all animation ids in AnimationIds
for the player_or_rig
.
changed in version 2.0.0-rc1
Renamed: -> LoadTracks
LoadAllTracks
Now requires Animations:Register()
before usage unless player_or_rig
is a player and Animations.AutoRegisterPlayers
is enabled.
LoadTracksAt
Creates animation tracks from animation ids in AnimationIds
for the player_or_rig
at path
.
added in version 2.0.0-rc1
GetTrack
Returns a player_or_rig
's animation track or nil.
PlayTrack
Returns a playing player_or_rig
's animation track.
StopTrack
Returns a stopped player_or_rig
's animation track.
StopPlayingTracks
Returns the stopped player_or_rig
animation tracks.
changed in version 2.0.0-rc1
Renamed: -> StopAllTracks
StopPlayingTracks
GetPlayingTracks
Returns playing player_or_rig
animation tracks.
StopTracksOfPriority
Returns the stopped player_or_rig
animation tracks.
GetTrackFromAlias
Returns a player_or_rig
's animation track or nil.
PlayTrackFromAlias
Returns a playing player_or_rig
's animation track.
StopTrackFromAlias
Returns a stopped player_or_rig
's animation track.
SetTrackAlias
Sets an alias to be the equivalent of the path for a player_or_rig
's 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 ServerScript
local player = game.Players.wrello
-- After the player's animation tracks are loaded...
local heavyAttackAlias = "HeavyAttack" -- We want this alias in order to call Animations:PlayTrackFromAlias(player, heavyAttackAlias) regardless what weapon is equipped
local currentEquippedWeapon
local function updateHeavyAttackAliasPath()
local alias = heavyAttackAlias
local path = currentEquippedWeapon .. "Combat"
Animations:SetTrackAlias(player, 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(player, heavyAttackAlias) -- Plays "FistsCombat.HeavyAttack" on the player's character
equipNewWeapon("Sword")
Animations:PlayTrackFromAlias(player, heavyAttackAlias) -- Plays "SwordCombat.HeavyAttack" on the player's character
RemoveTrackAlias
Removes the alias for a player_or_rig
's animation track.
AttachAnimatedObject
BetaAttaches the animated object to the player_or_rig
.
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 player_or_rig
.
tip
Enable initOptions.AnimatedObjectsDebugMode
for detailed prints about animated objects.
info
For more information on setting up animated objects check out animated objects tutorial.