{"id":"bigfootpp/sync","name":"sync","scope":"bigfootpp","platform":"roblox","description":"A lightweight animation and motion framework for Luau.","version":"0.2.0","latest":"0.2.0","versions":["0.1.0","0.2.0"],"license":"MIT","licenseRating":"safe","licenseCaveats":[],"licenseVerified":true,"dependencies":{},"integrity":"f5f42463f969836eb207b36c0288364a166a46abdb22822e083357a6c0abe945","likes":0,"downloads":0,"install":"forest install bigfootpp/sync","url":"https://forest.dev/p/roblox/bigfootpp/sync","files":"https://api.forest.dev/ai/package/roblox/bigfootpp/sync/files","readme":"# Sync\n\nA lightweight animation and motion framework for Luau and Roblox.\n\n---\n\n> [!WARNING]\n> This project is currently in **Beta**. Expect breaking changes.\n\n---\n\n## Installation\n\nAdd to your `wally.toml`:\n\n```toml\nSync = \"bigfootpp/sync@0.2.0\"\n```\n\n---\n\n## Quick Start\n\n### 1. Wrapping Animations\n\n```luau\nlocal Sync = require(ReplicatedStorage.Packages.Sync)\n\nlocal track = animator:LoadAnimation(animationInstance)\nlocal anim = Sync.Animation(track)\n\nanim:Play(0.2, 1.0, 1.0) -- fadeTime, weight, speed\nanim:Stop(0.2)\nanim:SetSpeed(1.5)\nanim:SetWeight(0.5, 0.1)\n```\n\n---\n\n### 2. 1D Blendspace\n\nBlend between animations using a single parameter (speed, slope, etc.):\n\n```luau\nlocal Sync = require(ReplicatedStorage.Packages.Sync)\n\nlocal blendSpace = Sync.BlendSpace1D({\n    { x = 0,   animation = idleAnim },\n    { x = 8,   animation = walkAnim },\n    { x = 16,  animation = runAnim  },\n}, 0.1) -- fadeTime\n\nblendSpace:Play()\n\nRunService.Heartbeat:Connect(function()\n    local speed = character.PrimaryPart.AssemblyLinearVelocity.Magnitude\n    blendSpace:Update(speed)\nend)\n```\n\n---\n\n### 3. State Machine\n\nStates are simple containers with Enter/Exit/Update signals. Links are defined on the StateMachine\n\n```luau\nlocal Sync = require(ReplicatedStorage.Packages.Sync)\n\n-- 1. Create manager and states\nlocal manager = Sync.StateManager()\nlocal idle = Sync.State(\"Idle\")\nlocal run  = Sync.State(\"Run\")\n\nmanager:RegisterState(idle)\nmanager:RegisterState(run)\n\n-- 2. Create links\nlocal toRun = Sync.ConditionalLink(idle, run, function()\n    return character:GetAttribute(\"IsRunning\") == true\nend)\n\nlocal toIdle = Sync.ConditionalLink(run, idle, function()\n    return character:GetAttribute(\"IsRunning\") == false\nend)\n\n-- 3. Create state machine, add links\nlocal sm = Sync.StateMachine(manager, idle) -- startingState is a StateClass\nsm:AddLink(toRun)\nsm:AddLink(toIdle)\n\n-- 4. Run\nmanager:Play()\n\nRunService.Heartbeat:Connect(function(dt)\n    sm:Update(dt)\nend)\n```\n\n#### Link Types\n\n| Function | Description |\n|----------|-------------|\n| `Sync.ConditionalLink(from, to, fn)` | Transition when `fn()` returns true |\n| `Sync.AutomaticLink(from, to, anim)` | Transition when `anim` finishes playing |\n\n#### StateMachine API\n\n| Method | Description |\n|--------|-------------|\n| `StateMachine.New(manager, startingState)` | `startingState` is a `StateClass` |\n| `sm:AddLink(link)` | Register a transition link |\n| `sm:GetCurrentStateLink()` | Get links for current state |\n| `sm:Update(dt)` | Evaluate links, update current state |\n| `sm:Restart()` | Return to starting state (keeps playing) |\n\n#### StateManager API\n\n| Method | Description |\n|--------|-------------|\n| `manager:RegisterState(state)` | Add a state |\n| `manager:GetState(name)` | Retrieve state by name |\n| `manager:ChangeState(name)` | Force state change |\n| `manager:Play()` | Start the machine (triggers Enter) |\n| `manager:Stop()` | Stop the machine (triggers Exit) |\n| `manager:Update(dt)` | Forward dt to current state |\n\n#### State Signals\n\nEach state exposes: `Entered`, `Exited`, `Updated(dt)`.\n\nOverride `OnEnter()`, `OnExit()`, `OnUpdate(dt)` on the state instance for custom logic.\n\n---\n\n## License\nMIT License. See `LICENSE`.","readmeTruncated":false}