ROBLOX has introduced an Animation Editor plugin for ROBLOX Studio. This tool allows developers to design and publish custom animations. Animations can still be created without the plugin using Keyframe Sequences, but the Animation Editor is recommended for all projects going forward.
The Animation Editor can be installed by logging into the ROBLOX website and installing the plugin. Alternatively, the plugin can be searched for in ROBLOX Studio by navigating to Tools > Manage Plugins > Find Plugins and searching for "Animation Editor". If you are using the ribbon style toolbar in Studio, Manage Plugins can be found under the Add-Ons tab.
To launch the editor, click on the Animation Editor button found in the toolbar. This will prompt you to select the base of the object you want to define animations for. This part must be named "HumanoidRootPart", and is already in the default player model as well as the four rigs that the editor provides.
After you select the base part, the editor window will open. This window shows a timeline and a list of all the parts in your model. At any place in the timeline you can create a keyframe where you can define how the model should look at that point in the animation. The position defined for each part in a keyframe is called a pose. When the animation runs, it will smoothly move parts between the poses defined in the keyframes.
To create a pose, drag the current keyframe indicator to the point in the timeline where you want to define your pose. Then, click on the part of the model you want to manipulate. Using the "R" hotkey, you can switch between rotating or moving the part. Parts in poses can be rotated in 45 degree, 10 degree increments or can be freely rotated. Parts can be moved in 1 brick or .2 brick increments or can be freely moved.
Creating a pose will automatically create a keyframe in your timeline. Note that you can create multiple poses per each keyframe (at most one per part in your model). A pose in the editor will appear as a square on the keyframe . You can also copy and paste poses in the editor. To do this, ctrl + click on the pose. Then, move the keyframe indicator to the point in the timeline you want the pose to be copied to and paste by pressing v. You can delete a pose by shift + right clicking on it.
To move a keyframe click and drag on the top of the keyframe in the timeline. This moves all poses that are in that keyframe.
To delete a keyframe shift + right click on the keyframe in the timeline and select "Delete". Note that the Animation Editor does not have an undo feature, so please be careful when deleting!
To rename a keyframe shift + right click on it in the timeline and select "Rename".
In your game you may have several different animations for player actions and states, but what happens when you want to start playing an animation when another is currently running? For instance, suppose you have a jump animation and an animation for when a character is standing still. To make the jump animation override the standing animation, priority should be used.
There are four levels of animation priority:
If you start playing an animation with a higher priority than the one that was already playing, the new animation will supersede the old. You can set the priority in the editor while making an animation by clicking on the priority menu and selecting your desired level.
Priority handles how to override animation behavior, but sometimes it is desirable to have two animation running at the same time. For example, if you make a waving animation, you may want that animation to be able to run while a character is walking or standing. When making an animation in the editor, you can select certain parts to include in the animation. The box next to the part name designates whether or not to include that part in the animation (by default all parts are included). When you play your animation, any excluded parts will continue to do what they were doing before the animation started.
Animations created in the editor are 2 seconds long by default but can be changed to be any length up to 30 seconds. To change the length of an animation in the editor, click on the last time label in the timeline. This will prompt you to enter a length in seconds. If you already have keyframes in your animation, they will stay in the same relative position. For instance, lets say you had an animation 2 seconds in length and had a keyframe at 1 second (halfway through they timeline). If you change the animation length to 3 seconds, the keyframe will remain at the halfway point and will trigger at 1.5 seconds.
When designing an animation in the editor, you can set the animation to automatically loop. The loop checkbox in the upper right corner of the editor will toggle looping on and off.
Once you are satisfied with your animation you can upload it to Roblox to use in your places. Click on the menu in the editor and select Export. Here you can either create a new animation or overwrite an existing one. After the animation has uploaded, make note of the asset id in the url that is provided:
You can use this url to create an animation in a script as seen in Using Animation in Games.
Animations can be imported into the Animation Editor to make tweaks and changes. Pressing the Import button in the editor will prompt for the Id of the animation. This is the numerical part of the animation's asset Id. Note that you can only import animations you have created. When you have finished changing the animation, you can export it again and overwrite the original animation or create a new one.
Animations can be added to a place either through a script or by adding an Animation object to the Workspace.
An animation object can be created in a script by instantiating an Animation and then pointing it to the Animation Id you want to use.
A model to be animated must have several parts to work. Firstly, it must have a Humanoid in which to load the animation itself with the LoadAnimation function. Secondly, it must also have a part called HumanoidRootPart. When it creates the animation from a timeline, the Animation Editor expects this part to exist. By default, player characters have both of these parts so only the animation has to be loaded in that case.
Player character animations should be played from a LocalScript .
Loading an animation into a Non-Player Character (or NPC) is almost the exact same as loading it into a Player Character. The main difference is that instead of loading the animation into a Humanoid part contained in the model, instead a NPC's animation should be loaded into an AnimationController. An Animation Controller can be added into the model through Insert Basic Object > AnimationController or in a script via Instance.new("AnimationController"). Note that the model still has to have a part called HumanoidRootPart (even if the model doesn't contain a Humanoid object).
Loading the animation into an AnimationController an AnimationTrack which can then be played:
Non-Player Character animations should be played from a server Script.
The Animation Editor can be used to create animations for custom models (not just the stock player character model), although this requires a bit more setup. The model still must have a part called HumanoidRootPart. The moving parts of the model must also all be connected with Motor6D parts. The HumanoidRootPart must also connect to the rest of the model via a Motor6D. The mesh rigs that the animation editor generates is a good example of the kind of part hierarchy to use:
Just remember that if your model is intended for a player character, the animation must be loaded into a Humanoid and run with a LocalScript. If the model is for a NPC, then it should be loaded into an AnimationController and run with a server Script.
This example shows how to play an animation on a player character when it touches a fence. Note that at the moment ROBLOX does not support sharing animations, so you will have to replace the animation ID with one you have made yourself. This may change in the future, so please periodically check the ROBLOX blog and development forums for any updates.
This example also makes use of the KeyframeReached event to handle playback of the animation. Above in Keyframes you can see how to name a keyframe in your animation to make use of this feature.
AnimationId - Gets and sets url to animation asset.
AdjustSpeed(float speed = 1) - Allows you to change the speed of an animation while it is playing.
Play() - Plays an animation from the beginning.
Stop() - Stops an animation.
KeyframeReached(string keyframeName) - Fires when animation reaches a new keyframe. keyframeName is the name of the current keyframe the animation has reached.
LoadAnimation(Animation animation) - Load animation into humanoid and returns an AnimationTrack for playback.