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!
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!
Please report any bugs/issues, and may your code always be blessed!
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
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?
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!
The weight member of the Animations table is actually used now, everytime a looped animation loops the module will now search a new random animation utilizing the weights and play that (similarly to how the default Animate script does)
Added a new Emotes module which allows you to set a PlayEmote BindableFunction to play your emote animations! (more detail below)
Made changePose work even if setCoreActive(false) was called (this is done with a is_Core optional argument which the module itself always passes as true, however you don’t need to!)
Initialized pose to “Idle” on join (you used to not play any animations upon joining)
The locations of the modules storing and preloading AnimationTracks have been moved to a new module called Animations which stores both CoreAnims and EmoteAnims!
If you wish to add your own custom emotes, simply just add it as a member in the EmoteAnims module.
Example Animate script utilizing the new changes
--[[
EXAMPLE ANIMATE SCRIPT
Location: StarterCharacterScripts
Name: Animate
]]
local AnimationController = require(script.Parent.AnimationController)
local Emotes = AnimationController.Emotes
local Core = AnimationController.Core
-- Set the emote BindableFunction to the one inside the script (HAS TO BE CALLED "PlayEmote"!!!)
-- so that the module can use it to play emotes
Emotes.setEmoteBindable(script.PlayEmote)
-- Set the running threshold to 16
-- If the player is moving below this speed, they are walking
-- Else, they are running
Core.setRunThreshold(16)
Core.PoseChanged:Connect(function(old, new)
if new == "Freefall" then
print("Player is falling!")
end
end)
Fixed emotes not replaying Idle animation upon ending
Fixed missing dependencies
Added playAnimation as a public static function for Core.
This function plays an animation for a specific pose no matter if the last pose is the same or not, unlike changePose which will only play the animation if the last pose isn’t the same as the new one.
Does this work for both R6 and R15, and NPC rigs?
I’ve tried to modify the Roblox’s default Animate script for an NPC and I constantly got this EXTREMELY annoying warning:
AnimationTrack limit of 256 tracks for one Animator exceeded, new animations will not be played.
Dispite numberous attempt of trying to fix and because the warning doesn’t point at the problem itself.
I’m running out of hope and I probably have to rewrite my own code again or make a post about it.
Regarding the flaws of Roblox’s Animate script itself, thank you for making this module.
I mean hopefully it shouldn’t do that? xd, it preloads the animation tracks so it shouldn’t exceed the animation track limit unless you have a ton for some reason
I just found out that the module must be inside the character for the animations to work.
Wouldn’t it be better that the module can be put somewhere else like in ReplicatedStorage and required using a script instead?
Judging by how you structured the module itself. It should have been an OOP object.
I don’t see why the module itself needs to be parented to a character every time instead of being in one place.
I would suggest adding the Character parameter when requiring the module by using this common method:
AnimationController.new(Character)
Maybe adding a Humanoid one as well but this is my personal suggestion since I like to rename my NPC’s Humanoid.
The current method works but it seems less feasible when there’s a lot of players in the game and there’s AnimationController inside every character along side the Roblox’s Animate script.