SimpleAnimate | An easy-to-use & flexible replacement for the default Animate script

Have you tried working with the default Animate script for your game with super cool animations, and got really frustrated because the code was messy and long?
seriously, what even is this??

Well, do I have the solution for you!
Presenting…

SimpleAnimate!

SimpleAnimate is a module that you can require via a LocalScript and it’ll play your animations like the default Animate script would, but it’s more flexible & interactable!

Documentation:

Core

The Core module is the module that handles all core/default animations (Walking, running, jumping, swimming, climbing, etc).
There are quite a few functions to go over for the Core module, so let’s go through them one by one!

Functions
  1. Core.setRunThreshold(new: number): ()

    • All this function does is alter at what speed does the Core module differentiate walking from running.
      For example, if you do Core.setRunThreshold(20), then if the Players walk speed is below 20, they will be considered to be walking.
      Otherwise, they will be considered to be running!

  2. Core.setCoreActive(new: boolean?): ()

    • This function sets the current Core active state to a boolean.
      If the Core active state is false, then no pose changes will happen, EVER, until it is set back to true!
      Useful if you want to just… make the Player stop being animated, for whatever reason!

  3. Core.changePose(pose: PoseType, speed: number?): ()

    • If you wish to change the current pose to another pose, then use this function!
      For example, if you do Core.changePose("Swimming", 50), now the Player will be swimming at the SPEED OF LIGHT!!! (Even if they aren’t really swimming!)
      Note that this requires the Core module to be active (see Core.setCoreActive(...)), so any pose changes may be overridden by default behaviour :sweat_smile:

  4. Core.stopCore(): ()

    • Stops all currently running core animations.
      Useful if you called Core.setCoreActive(false) and also want to stop all of the animations too!

  5. Core.getAnimation(pose: PoseType): AnimationTrack

    • This returns the designated AnimationTrack for the specified pose.
      For example, if you did Core.getAnimation("Swimming"), then it would return the AnimationTrack that gets played when the Player is swimming!

  6. Core.getCurrentTrack(): AnimationTrack

    • This returns the current playing AnimationTrack.

And that’s basically all of the functions for Core, now onto the events! Or should I say, event… because theres just 1.

Events
  1. Core.PoseChanged :: RBXScriptSignal<PoseType, PoseType, AnimationTrack>

    • As the name suggests, this event fires whenever the current pose changes to another one.
      It passes the old pose as the first argument, the new pose as the second argument, and the currently playing AnimationTrack as the third!


And that's all for the `Core` module! Now, onto the `Action` module to see some action!
Action

The Action module is the module that you use to play any Action priority animations, such as sword slashing, tool lunging, or hopping!

Functions
  1. Action.addAction(name: string, id: string, looped: boolean?, priority: Enum.AnimationPriority?): AnimationTrack

    • This function preloads an animation content ID to be played later with Action.start()!

  2. Action.removeAction(name: string): ()

    • This function removes an AnimationTrack added by Action.addAction(...)!, if you wish to discard any tracks for some reason, use this!

  3. Action.start(name: string, fadeTime: number?, weight: number?, speed: number?)

    • This function plays an AnimationTrack added by Action.addAction(...), with some arguments.

  4. Action.stop(name: string, fadeTime: number?)

    • This function stops an AnimationTrack added by Action.addAction(...), with some arguments.

And that’s it for Action!, no events or anything…


Aaaand that's all for the `Action` module! Now time for the interesting stuff...
How To Add Your Own Animations
  1. Select the CoreAnims module, like seen in this picture!
    image
  2. Then open it, and uncomment the Animations table for your RigType (R6 or R15). In this example, I’m gonna be using R15
  3. Now just edit the animation IDs or weights (Or even add new things! be careful though…) to your hearts content!
    Make sure to not edit the keys of the tables though (like “Swimming”, “Walk”, “Run”, “Freefall”, etc…), unless you know what you’re doing, it’s most likely gonna break everything dx
Structure

Here is a nice little flow chart of how SimpleAnimate is structured!

flowchartanimate

Example Usage
  1. Detecting new poses!
--CLIENT

local AnimationController = require(path_to_simpleanimate)

local Core = AnimationController.Core

Core.PoseChanged:Connect(function(old, new)
      print(`A new pose: {new}!`)
end)

  1. Tool animations!
--CLIENT

local AnimationController = require(path_to_simpleanimate)

local toolHold = "rbxassetid://1234567890"

local Action = AnimationController.Action

Action.addAction("Holding", toolHold)

local character = game.Players.LocalPlayer.Character

character.ChildAdded:Connect(function(child)
    if not child:IsA("Tool") then return end
    Action.start("Holding")
end)
character.ChildRemoved:Connect(function(child)
    if not child:IsA("Tool") then return end
    Action.stop("Holding")
end)

Download SimpleAnimate here! →
AnimationController.rbxm (8.0 KB)

(Make sure to parent the module to StarterCharacterScripts, otherwise replication won’t work!)

And if you haven’t already, please check out my other modules SimpleZone and BufferConverter!

Please report any bugs/issues, and may your code always be blessed! :heart:

7 Likes

If you have any questions on, for example, how to modify certain behaviour of this module, feel free to ask me!

I do in fact, how could I modify your module to use already, pre-existing AnimationTracks loaded on the character?

Are you trying to use them as core or action animations? Be more specific for what you’re trying to do and I’ll help you out :slightly_smiling_face:

I already have a module under the Player which holds a big table of all animations loaded on the Character, and I want to switch your module’s behavior of creating them at runtime to loading each of those animations with the prefix of “Animate_”
e.g.

Walk = {
	{id = "",weight = 10}
}

to

Walk = nil
-- --> end of Animations table
for Name in Animations do
	Animations[Name] = AnimationsModule:GetAnim("Animate_"..Name)
end

Ah, you can simply do this!

for pose, animInfo in Animations do
	for _, idInfo in animInfo do
		idInfo.anim = AnimationsModule:GetAnim("Animate_"..pose)
	end
end

And then just replacing the part that preloads the animation with it
image

Thank you, that’s useful. I was meaning to get rid of the default “id” and “weight” keys in the default Animations table… Can I safely remove those or are there needed params?

Nope, if you remove the default animation preloading theres pretty much nowhere else that uses the id and weight.

2 Likes

If you want to edit it more, I suggest looking under the PoseController module under Core. It controls all the Core animations, and it’s pretty short too!