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.
- 1 Using the Editor
- 2 Using Animation in Games
- 3 API
- 4 See also
Using the Editor
Launching the Editor
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 delete a keyframe, click on the keyframe button and press "Delete". You can undo this action by pressing Shift + Z
To rename a keyframe, click on the keyframe button and press "Rename".
To copy a keyframe, click on the keyframe button and select Copy. To paste the keyframe, move your cursor and press Shift + V.
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:
- Core (lowest priority)
- Action (highest 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.
To change the length of your animation, click on the Edit and click "Change Length". Your animation can be up to 30s long. When you change your animation length, keyframes stay in relative position. So a keyframe at the end of your animation stays at the end, a keyframe in the center stays in the center, etc. (This means that keyframe times do change)
To add or remove time (based on where the cursor is positioned) click on the Edit button and select 'Add Time At Cursor'/'Remove Time At Cursor'. This inserts/removes time wherever the cursor is located. This means keyframes will be pushed forward / pulled back depending on how much time you add/remove.
When designing an animation in the editor, you can set the animation to automatically loop. The settings menu has an option to turn looping on / off.
Once you are satisfied with your animation you can upload it to Roblox to use in your places. Click on the File 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 (under the File menu) 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.
Pressing the File menu in the editor will give you the following options:
Pressing the Edit menu in the editor will give you the following options:
Pressing the Settings menu in the editor will give you the following options:
Using Animation in Games
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.
Playing Animation in Player Character
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 .
Playing Animation in Non-Player Character
Loading an animation into a Non-Player Character (or NPC) is almost the exact same as loading it into a Player Character. If your NPC has a Humanoid, you can simply load the animation and play it just like a regular player (except use a Script instead of a LocalScript to load the Animations). If your NPC is something without a Humanoid (like animating a door, windmill, etc) then you should use an AnimationController.
Loading the animation into an AnimationController an AnimationTrack which can then be played:
Animating Custom Models
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.