AnimateController - Modular Animate script for tool animations & more!

AnimateController

AnimateController is a module to replace the default Animate script to remove all the bloat, support new animations (such as landed, swimming, running, and sprinting) and, most importantly, support tool animations. It aims for customizability (changing animations in real time even if they’re playing), performance, readability, and other custom behaviors such as easily simulating animated NPCs.


Information


Examples

Elementalism is a game I solo develop and uses this module if you want to test how it works.


Notes

  • Don’t try to change any values from the returned AnimateController directly. Use the methods instead to assure nothing breaks.
  • The script removes the default emotes system as it’s designed for games who have (and most do) their own emotes system. If you are used to having the default emotes system, make your own implementation that offers the default emotes and play them at a priority higher than Core.
  • The animations in the video aren’t public, they are mine and set by me; they don’t come with the model. Roblox already offers some default animations, but Landed, LandedRoll, Swim, SwimIdle, and Run needs to be set by you.
  • Although the Idle animation is set to a Folder containing animations by default, you can delete it and use only a single Animation instead. You can also set any animations to a Folder with multiple animations inside for randomization.
  • In the tool animations showcase, the tool models aren’t named Handle nor parented to the Tool itself. The script does not rely on a supposed “Handle” when there’s a properly named animation under the Tool. You can use your own tool handle equipping logic and just set the animation.
  • Although I don’t have any examples of uses of tool idle, walk, and run, they are still a feature! Due to the custom tool holding, I personally never need a custom idle/walk/run because the tool holding mixes with the default idle/walk/run, but an example would be a Boxing Tool that plays a custom boxing stance idle animation.

If you have any suggestions, please comment!

20 Likes

v1.0.1

  • Added a version indicator at the top of the script.
  • Changed RegisterAnimation to only support an Animation as its first parameter and added an “overrideName” parameter.
  • Small changes to other parts of the script.
  • Made Jump play with Movement priority instead of Action.
1 Like

MAJOR UPDATE - v1.1

As said before, I’d turn this into a module. It’s now named AnimateController. The post was updated with all the functions in the new module.

  • I am sure that it works in R15 now.
  • With the module, parent it to ReplicatedStorage and require in an Animate script to start using it.
  • Added an AnimateParams; a table approach for the old “Script Attributes”.
  • You can now modify animations in real time. Useful for games that modify default animations when a character is in a specific state.
  • A default Animations is set when the object is created; this way, if you happen to modify default animations and then want to return to default after a certain state is removed from a character, you can use the new ResetToDefaultAnimations method.
  • It’s now possible to use this to load NPC animations in the client.
  • Increased default LandedDuration to 0.6.
1 Like

Nice module will be taking a look at it later on.

how would one go about making it so an animation alternates when doing multiple jumps and whatnot

For my game I currently have it so the player has some base animations (Walk, Idle, Jump)
There are also different dash and Run animation that can be changed
and there are also animations (Running w/ a tool, idle w/ a tool, jumping w/ a tool) that will be played when a certain type of tool is equiped (Projectile, katana, long sword, short sword)

How would one go about making it w/ ur module (if u can provide a detailed example or an example baseplate file would be best)

1 Like

how would one go about making it so an animation alternates when doing multiple jumps and whatnot

I think you can do that by changing the Jump animation to a Folder and adding several jump variations in it. You can also set their weighted chance with an attribute to the animation as said in the post.

For my game I currently have it so the player has some base animations (Walk, Idle, Jump)
There are also different dash and Run animation that can be changed
and there are also animations (Running w/ a tool, idle w/ a tool, jumping w/ a tool) that will be played when a certain type of tool is equiped (Projectile, katana, long sword, short sword)
How would one go about making it w/ ur module (if u can provide a detailed example or an example baseplate file would be best)

There are some examples in the post and some explanations in the READ_ME and Example scripts in the model, but indeed a more direct explanation is better.

This is a replacement to the default Animate script, therefore it’s only for animations that are related to HumanoidStateTypes, so changing your dash animation would be on your end. About run, I show an example of how you’d code it in the post:

Finally the tool animations. Simply add Animations under a Tool (or ObjectValues that reference an Animation). It should look like this:
image
Or this:

As I said too, there’s another option named ToolHolding which sets a custom holding animation for that tool. It’s what the examples in the post use for tool animations. It will play while running or walking or standing, so it’s an easy way to set up some kind of custom walk/idle/run animations.

v1.1.1

  • Fixed ResetToDefaultAnimations not working due to referencing the same table as Animations, which would cause DefaultAnimations to be changed when Animations also was.
  • Changed the auto fill in AnimateParams being fixed. Now it just detects your Humanoid’s RigType and choose one of the options to use as fill in.

v1.1.2

  • The object no longer needs to completely reload the animate handler upon changing an the animations set by calling :Unload() and :Load(). Changing animations will reload in real time even if they’re already playing without restarting them.

Showcase of new behavior:


backpedalling would be cool :eyes::eyes::eyes:

Crouching would be even cooler :eyes::eyes::eyes:

i tried adding it myself and failed horribly

in your “documentation” i did not find how to play different animations via the module

anyways great work

1 Like

@PLAY9591 @xpstm
As stated this is mainly just a replacement to the default Animate script, it is not exactly a full movement system. I’m not sure what n9591 means with backpedalling (please provide an example if you can because I don’t know what this means), but crouching is possible using :ChangeAnimation("Walk", crouchAnim) and reverting to defaults after crouching stops with :ResetToDefaultAnimations() (assuming your crouching has a speed lower than the RunDetectSpeed param).

However, anything that transcends the default Humanoid states such as dashing is on your end. This isn’t exactly a better way to play animations in general, it’s specifically about the Animate script.

Another example I can give is for some games who have a running to sprinting feature where after running for 5 seconds you start sprinting. This is also possible to implement by changing the Run animation or adding a check in the Running entered state function. Perhaps I might actually make this supported by the module without devs having to do any changes, who knows.

I appreciate the comments anyway.

1 Like


so i just play custom animations such as opening a cupboard on the animator its self

Correct. It should be possible to implement crouching though like I tried to explain. You might want to do :ChangeAnimation("Idle", crouchIdle) as well though.

However this assumes you can directly access your character’s AnimateController. If you can’t, just connect BindableEvents to some functions to use it from anywhere. I didn’t add a way to get the controller from any script because that implies in the need of a container table which also needs manual clean up. I actually do have a way to do the clean up without needing devs to do it manually on character destroying, but that would imply in the module depending on another module I have which I don’t really wanna do at least yet.

yup, thanks for the help it feels great!

1 Like

No problem! You might want to change the WalkSpeedDividend though so the walk (in this case, crouch walk) animation plays faster or make your crouch animation keyframes less spaced.

Game looks great btw!

1 Like

v1.1.3

  • Removed the check in ChangeAnimation() that would throw a warning if you attempted to change an animation that’s set to nil.
  • Added a new type of animation: Sprint. It has params similar to Run. Will play when an even higher speed than the one for Run is reached. Useful for games with a jogging/running > sprinting mechanic.

v1.1.4

  • Added support for ToolSprint.
  • Secondary AnimationTracks now play with Movement priority instead of Action.
  • Included info about tools in the README.

About issues, if anyone makes use of ToolIdle (or any other) with ToolHolding at the same time, I’m aware that both will mix instead of ToolIdle (and others except for ToolHolding) being prioritized. Couldn’t find a solution yet that doesn’t imply in messing with animation priorities, which could impact experiences that use animations whose priorities are set to Action.

I am looking for something that can easily play an animation, such as an attack, but then mid animation (if the attack was blocked) transition smoothly to a staggered or stunned animation. Would this module work for that, and how would I do that? Thanks.

You don’t need a module to do that. This module is a replacement for the Animate script, no modules will replace the default methods to play animations.