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
-
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 doCore.setRunThreshold(20)
, then if thePlayer
s walk speed is below 20, they will be considered to be walking.
Otherwise, they will be considered to be running!
- All this function does is alter at what speed does the
-
Core.setCoreActive(new: boolean?): ()
- This function sets the current
Core
active state to a boolean.
If theCore
active state isfalse
, then no pose changes will happen, EVER, until it is set back totrue
!
Useful if you want to just… make thePlayer
stop being animated, for whatever reason!
- This function sets the current
-
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 doCore.changePose("Swimming", 50)
, now thePlayer
will be swimming at the SPEED OF LIGHT!!! (Even if they aren’t really swimming!)
Note that this requires theCore
module to be active (seeCore.setCoreActive(...)
), so any pose changes may be overridden by default behaviour
- If you wish to change the current pose to another pose, then use this function!
-
Core.stopCore(): ()
- Stops all currently running core animations.
Useful if you calledCore.setCoreActive(false)
and also want to stop all of the animations too!
- Stops all currently running core animations.
-
Core.getAnimation(pose: PoseType): AnimationTrack
- This returns the designated
AnimationTrack
for the specifiedpose
.
For example, if you didCore.getAnimation("Swimming")
, then it would return theAnimationTrack
that gets played when thePlayer
is swimming!
- This returns the designated
-
Core.getCurrentTrack(): AnimationTrack
- This returns the current playing
AnimationTrack
.
- This returns the current playing
And that’s basically all of the functions for Core
, now onto the events! Or should I say, event… because theres just 1.
Events
-
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 playingAnimationTrack
as the third!
- As the name suggests, this event fires whenever the current pose changes to another one.
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
-
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()
!
- This function preloads an animation content ID to be played later with
-
Action.removeAction(name: string): ()
- This function removes an
AnimationTrack
added byAction.addAction(...)
!, if you wish to discard any tracks for some reason, use this!
- This function removes an
-
Action.start(name: string, fadeTime: number?, weight: number?, speed: number?)
- This function plays an
AnimationTrack
added byAction.addAction(...)
, with some arguments.
- This function plays an
-
Action.stop(name: string, fadeTime: number?)
- This function stops an
AnimationTrack
added byAction.addAction(...)
, with some arguments.
- This function stops an
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
- Select the CoreAnims module, like seen in this picture!
- Then open it, and uncomment the Animations table for your RigType (R6 or R15). In this example, I’m gonna be using R15
- 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!
Example Usage
- 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)
- 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!