AnimationRegistry
Global singleton registry for animation configs.
AnimationRegistry holds all animation configuration data for the game. It must be
initialized once at startup, before any AnimationController is created. Controllers
look up their animation configs from this registry by name.
local AnimationRegistry = require(ReplicatedStorage.Motix.Modules.AnimationRegistry)
local Registry = AnimationRegistry.GetInstance()
Registry:Init({
{
Name = "Idle",
AssetId = "rbxassetid://YOUR_ID",
Layer = "Base",
Looped = true,
Priority = 0,
FadeInTime = 0.2,
FadeOutTime = 0.2,
Speed = 1.0,
Weight = 1.0,
CanInterrupt = true,
Tags = {},
Additive = false,
},
})
One-time initialization
Init may only be called once. Calling it a second time throws an error. Initialize at
the top of your startup script before requiring any other Motix modules that create
controllers.
Functions
GetInstance
Returns the singleton AnimationRegistry instance.
The instance is created lazily on first call. All calls return the same object.
local Registry = AnimationRegistry.GetInstance()
Init
Initializes the registry with an array of animation configs.
Each config is validated at call time. Errors throw immediately with a descriptive message.
Required fields per config:
| Field | Type | Description |
|---|---|---|
Name |
string |
Unique animation name. Referenced by Controller:Play() and Controller:Stop(). |
AssetId |
string |
Roblox animation asset ID ("rbxassetid://..."). |
Layer |
string |
Layer this animation belongs to. Must match a LayerProfile name on the controller. |
Looped |
boolean |
Whether the animation loops. |
Priority |
number |
Conflict priority within the layer or group. |
FadeInTime |
number |
Seconds for the animation to fade in. |
FadeOutTime |
number |
Seconds for the animation to fade out. |
Speed |
number |
Playback speed multiplier. |
Weight |
number |
Blend weight within its layer. Range (0, 1]. |
CanInterrupt |
boolean |
Whether this animation can be interrupted by a lower-priority group request. |
Tags |
{ string } |
Tag strings for batch operations via PlayTag. |
Additive |
boolean |
Whether the animation is played in additive blending mode. |
Optional fields:
| Field | Type | Description |
|---|---|---|
Group |
string? |
Exclusive group name. nil means no group. |
MinDuration |
number? |
Minimum seconds before interruption is allowed. |
Metadata |
table? |
Arbitrary key-value table stored with the config. |
All configs are deep-frozen after validation. Modifying a config after Init has no
effect on the registry.
Registry:Init({
{
Name = "Fire", AssetId = "rbxassetid://FIRE_ID",
Layer = "UpperBody", Group = "WeaponAction",
Looped = false, Priority = 10,
FadeInTime = 0.05, FadeOutTime = 0.1,
Speed = 1.0, Weight = 1.0,
CanInterrupt = false, Tags = { "weapon" }, Additive = false,
},
})
GetByName
AnimationRegistry:GetByName(Name: string--
The animation name to look up.
) → AnimationConfig?--
The frozen config, or nil.
Returns the frozen AnimationConfig for the given name, or nil if not found.
local config = Registry:GetByName("Idle")
if config then
print(config.AssetId)
end
GetByTag
AnimationRegistry:GetByTag(Tag: string--
The tag to look up.
) → {AnimationConfig}--
Frozen array of configs with this tag.
Returns all animation configs registered under the given tag.
Returns an empty table if no animations have the tag. The returned table is frozen.
local footsteps = Registry:GetByTag("footstep")
for _, config in footsteps do
print(config.Name, config.AssetId)
end
GetByGroup
AnimationRegistry:GetByGroup(Group: string--
The group name to look up.
) → {AnimationConfig}--
Frozen array of configs in this group.
Returns all animation configs registered under the given group name.
Returns an empty table if no animations belong to the group. The returned table is frozen.
local weaponAnims = Registry:GetByGroup("WeaponAction")
IsInitialized
AnimationRegistry:IsInitialized() → booleanReturns whether the registry has been initialized.
if not Registry:IsInitialized() then
Registry:Init(myConfigs)
end