AnimationSounds
Fast, versatile & secure animation sounds
How does it work?
The system constantly sweeps through all the rigs and their playing animation tracks, connecting to the tracks event, and cleaning up when the track isn’t playing anymore.
Download:
Roblox Model
Copyable Roblox Place (Recommended to look through) - An example implementation with some helpful utility modules that work nicely with this system
Features:
- Fully client sided - no remotes are used
- Versatile yet user friendly - can be easily used in any game
- Fast - updates take a fraction of a ms
- Secure - protection against exploiters spamming animations
API:
Module.AddRig(Animator: Animator, RigValue: any)
Adds an animator to the system. “Rig Value” can be anything
Module.RemoveRig(Animator: Animator)
Removes an animator from the system
Module.SetRigEnabled(Animator: Animator, Toggle: boolean)
Sets whether a rig will updated and will callback for sounds
Module.AddCallback(Callback: Callback): number
Adds a callback function to the system. The callback will be called when any rig reaches a sound marker for any animation. The callback should be used to actually play a sound. The function returns a number which acts as in ID for the callback
Module.RemoveCallback(Id: number)
Using an ID which is returned from AddCallback, you can remove the callback from the system
Adding sound markers to your animation:
-
Add a new marker to your animation
-
The name should be “Sound” (unless you change it in the module’s settings), and the parameter can be whatever you’d like
Settings:
Settings can be found at the top of the module with explanations
Heat and Focusing, what is it?
Each rig has their own heat and focusing
-
“Heat” is a number that increments every time a sound marker is reached. It resets every SOUND_HEAT_STEP. If the heat surpasses SOUND_HEAT_MAXIMUM, it will “overheat”. When a rig is overheated, it wont callback for any sounds for SOUND_OVERHEAT_PUNISHMENT_DURATION.
-
“Focusing” is a table of animations. Only focused animations can callback for sounds. The max amount of focused animations is determined by MAXIMUM_FOCUSED_TRACKS_AT_ONCE. The minimum amount of time a track has to be focused for is determined by MINIMUM_FOCUS_TIME
Closing
This system will require a bit of setup! Although after you get it in your game and working, it’s very easy to work with. I don’t require any credit for this, but it would be appreciated if you’re feeling kind.
Footage
Update time for 50 rigs playing a footstep sound every 0.5 seconds when walking:
I’m using this system in my own personal game: