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:
Constructor
-
SimpleAnimate.new(rig: Model, coreAnimations: AnimationsList?, emoteAnimations: AnimationsList?, stateMachine: any?)
- To create a new
AnimationController
that contains all the controllers, you must first call this constructor function, with the rig as the only required argument (I’m sure the other arguments explain themselves!
If they don’t though, feel free to ask in the replies.)
- To create a new
Core
The Core
controller is the controller which handles all core movements of rigs, such as walking, running, jumping, swimming and climbing!
The Core
controller itself is divided into 2 more controllers, the Connections
controller (which handles state changes) and the PoseController
(which handles tracking poses and animations)
Let’s go through the PoseController
first since that’s the longest (and probably the one you’re gonna use the most often!)
-
PoseController:SetCoreActive(value: boolean)
- Now you may be wondering, what does “active” mean? Why does the
PoseController
need to be “active” or not?
Well, essentially what theactive
property does is it determines wether or not theConnections
controller can interact with thePoseController
during state changes.
The reason this is a function is because you may wanna block that interaction to play your own core animations (like swimming using a custom swimming system!)
- Now you may be wondering, what does “active” mean? Why does the
-
PoseController:StopCore()
- Stops all currently running core animations.
Note thatPoseController:SetCoreActive(false)
does not stop core automatically!
This means if you want to stop any ongoing core animations you’ll have to call this function manually.
- Stops all currently running core animations.
-
PoseController:GetCoreActive() : boolean
- Returns the current active state of the
PoseController
.
- Returns the current active state of the
-
PoseController:ChangePose(pose: PoseType, speed: number?)
- This method does exactly as it says, it changes the current pose of the
PoseController
topose
.
However, ifpose
is the same as the current pose, it won’t play a new animation!
Note that if thePoseController
is still “active”, it’ll probably override any pose changes.
- This method does exactly as it says, it changes the current pose of the
-
PoseController:PlayAnimation(pose: PoseType, speed: number?, fadeTime: number?)
- This method is similar to
PoseController:ChangePose()
, except it doesnt care wether or notpose
is the same as the current pose, it plays the animation anyway!
May be useful in certain cases.
- This method is similar to
-
PoseController:GetRandomAnim(pose: string, animsTable: AnimationsList?)
- This method uses weighted random selection to get a random AnimationTrack from a list of animations (of type AnimationsList, see the
Types
module for more details.)
- This method uses weighted random selection to get a random AnimationTrack from a list of animations (of type AnimationsList, see the
-
PoseController:GetCurrentTrack()
- Gets the current running core AnimationTrack.
- Gets the current running core AnimationTrack.
-
PoseController:GetPose()
- Gets the current pose of the
PoseController
.
- Gets the current pose of the
And that’s all for PoseController
!
Now theres 1 more method for the other controller, Connections
-
Connections:SetRunThreshold(value: number)
- This method sets the run threshold for the
Connections
controller.
What exactly is the run threshold? Well it’s the walkspeed at which the rig is considered running.
If the rig is walking slower than this, it’s walking. Otherwise, running!
- This method sets the run threshold for the
Action
The Action
controller is the controller which handles all actions, such as emotes and well, actions!
Theres not much methods to go over but heres all of them!:
-
Action:Create(name: string, anim: string | Animation, looped: boolean?, priority: Enum.AnimationPriority?) : AnimationTrack
- This method loads a new action using
anim
(an AssetId for an animation or an actual Animation instance) to be used byAction:Play()
,Action:Stop()
,Action:Remove()
andAction:Get()
and returns it.
Note that the first 3 methods will warn you if the action isn’t created first with this method.
- This method loads a new action using
-
Action:Play(name: string, fadeTime: number?, weight: number?, speed: number?) : AnimationTrack
- This method plays a loaded action and returns it.
- This method plays a loaded action and returns it.
-
Action:Stop(name: string, fadeTime: number?) : AnimationTrack
- This method stops a loaded action and returns it.
- This method stops a loaded action and returns it.
-
Action:Remove(name: string)
- This method unloads a loaded action.
- This method unloads a loaded action.
-
Action:Get(name: string) : AnimationTrack?
- This method returns a loaded action or none if doesn’t exist.
- This method returns a loaded action or none if doesn’t exist.
-
Action:SetEmoteBindable(emote: BindableFunction)
- This method sets an emote bindable to be used for processing emotes.
Note that the BindableFunction has to be calledPlayEmote
to be properly registered by Roblox CoreScripts.
- This method sets an emote bindable to be used for processing emotes.
Download SimpleAnimate here! →
AnimationController.rbxm (11.1 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!