Из этой статьи вы узнаете о том как можно сделать простую анимацию в Роблокс используя Roblox Studio. Отталкиваясь от этого примера вы сможете самостоятельно создавать более сложные анимации и использовать их в собственных проектах.
Пошаговая инструкция по созданию анимации
2. В окне предпросмотра появиться выбранная модель.
3. Для того что бы создать анимацию, необходимо нажать кнопку «Animation Editor» и в появившемся интерфейсе кнопку «Create»
4. Откроется вкладка анимирования персонажа. Первым делом выставим приблизительное время анимации в секундах.
5. Если кликнуть по какой то части тела появиться визуальный джойстик с помощью которого можно вращать часть тела в той или иной плоскости.
6. Выставите ползунок на timeline на ноль и понажимайте на все части тела которые хотите анимировать для того что бы задать начальный чекпоинт положения частей тела. Если на timeline появился белый кристаллик значит вы все сделали правильно и программа запомнила начальное положение конечности.
7. Перетяните ползунок на timeline на 1 секунду вперед и измените положение любой конечности, например руки (сделаем анимацию махания).
8. Создайте на timeline чекпоинты изменения положения руки так, что бы это было похоже на приветственное махание, а в самом конце вставьте чекпоинты из нулевой отметки (их можно скопировать Ctrl + C и вставить Ctrl + V).
9. Если нужно зациклить анимацию нажмите кнопку в виде закрученной стрелочки (смотри скриншот).
10. Что бы сохранить анимацию нажмите «File» — «Export»
11. В открывшемся меню выберите «Create New»
12. Введите название для анимации и описание (желательно на английском) и нажмите Finish.
13. Появиться окно со ссылкой на анимацию. Сохраните цифровой код id перед /redirect он нам еще понадобиться.
14. Свои анимации можно посмотреть во вкладке «Create» — «Animations»
15. Для того что бы присоединить анимации к тому или иному персонажу на своей карте, необходимо создать его в Roblox Studio. В левой вкладке выбрать Script (что бы быстро его найти введите в поиск Script)
16. В новом окне в поисковой строке введите «animation» и выберите его в окне чуть выше;
17. Вставьте скопированный ранее id анимации в поле «Animationid»
18. Пропишите этот код в скрипт (внимание: название файла анимации было изменено с «Animation» на «ahmed». Для нормальной работы скрипта можете либо поменять имя либо изменить в коде «Animation» на «ahmed»).
19. Проверяем в интерфейсе рядом с окном предпросмотра что бы не стояла галочка «Anchored»
20. Заходим на свою карту и проверяем работу анимации.
Видео инструкция
Animating Parts
Players can get feedback to whether or not their actions are doing anything with animations. This can be a tree shaking when hit, or pet cheerfully bouncing when fed. In this case, we’ll show you how to make a button that moves when the player clicks it.
Is This Tutorial For Me? »
This tutorial includes some basic scripting and part creation. If you’re new to creating scripts and parts, we recommend you follow along with Intro to Coding and Game Design first.
Tweening with Animations
One way of animating objects is using tweens. A tween, short for in-between, is a word for the process of changing a starting value to an ending value over a certain amount of time. Tweens can be used to change properties such as position, color, or rotation.
Project Setup
For this project, a tween will move an object from a starting position to a goal position.
Using Models »
If you’re using a model with many parts, pick one part to move (such as the button in this example), and put the MoveTween script as it’s child.
Adjusting the Move Tween
With the script added, you can customize it to suit the needs of your game. The button can be tweened to move in directions like forward and back, or up and down.
Changing Position
Remember, tweens transition from a starting value to a goal value. This script uses CFrame to move the button in a direction relative to its current position. That direction is controlled in Line 28 of the script.
On that line, a new CFrame is created using X, Y, and Z coordinates. In this example, the button moves relative to its Y axis.
For example, this line will move it relative to its X axis instead.
Tween Time and Distance
The script includes the following variables that affect the tween’s movement. Capitalized names like TWEEN_TIME are written specifically for this script to be modified.
Try changing the value of one variable below:
Script Notes and Limitations »
Tweening Other Properties
Most properties with a numerical data type can be tweened. This section includes some common properties, like rotation, that can be used to bring more player feedback into your game. Keep in mind, you can also tween multiple properties at once.
For a full list of properties, see the TweenService API page.
Rotation
For rotation, combine tweening and Cframes instead of just using Vector3. Rotation tweens can be used to make creatures wiggle when pet, or coins twirl as they’re picked up.
In the next script example, the creature’s position and rotation are both tweened when clicked to show how happy it is when being pet.
Using Animations in Games
Changing Default Animations
To change a default character animation, you’ll first need to locate the desired animation’s asset ID.
Catalog Animations
To use a catalog animation, locate its asset ID as outlined on the articles/catalog animations|Catalog Animations reference page.
Custom Animations
Changing a Default Animation
Once you have a valid animation asset ID, you can easily replace any of the default Roblox character animations:
Multiple animations may be used for the same action — note, for instance, that there are two default “idle” animations. When multiple animations exist for a character state, the Animate script will randomly choose which one to play, although the outcome can be influenced by changing the animation’s Weight value.
When assigning weight values, the probability of an animation being chosen is:
In the script below, this means that Animation1 will play ⅓ of the time the character is idle, while Animation2 will play ⅔ of the time.
Playing Animations Directly
In some cases you’ll need to play an animation directly from inside a script, for instance when the player presses a certain key, picks up a special item, etc.
Humanoids
Non-Humanoids
Animation Editor
The Animation Editor plugin allows you to design and publish custom animations on rigs.
Interface
Media and Playback Controls
The name of the animation.
Opens a pop-up menu with the following menu items:
Timeline
A scrubber that marks the current frame position.
Time units that allow you to move the scrubber to a precise time unit.
A keyframe that marks the change in position or orientation of a part.
Either expands or contracts the time unit marks.
Opens a pop-up menu with the following menu items:
Track List
The name of the rig.
Opens the Manage IK window.
Opens a pop-up menu of additional tracks you can add to the track list.
The track displaying the name, position, and rotation of the part that has been moved or rotated to a new position or orientation.
Opens a contextual menu with the following menu items:
Opening the Animation Editor
To create an animation within Studio, you will first need to open the Animation Editor.
In the menu bar, navigate to the Plugins tab.
Creating an Animation
Before you create an animation, you should have a rig within your experience. If you don’t have a rig available, insert a pre-built rig with the Build Rig plugin. The pre-built rigs have all of the basic parts and mechanisms to build a character animation.
Select the rig you want to create an animation for. A dialog displays.
Creating Poses
A pose is when you move and/or rotate parts of a rig (hands, feet, torso, etc.) to specific positions. After you create multiple poses, the Animation Editor will run between them with a defined easing setting to smoothly animate the rig from pose-to-pose.
For example, consider a simple animation where a humanoid character turns to look 45В° to the left. This animation involves two poses:
To create a pose:
In the Animation Editor window, navigate to the timeline, then click-and-move the scrubber to the frame position where you want to set the pose. By default, timeline units are expressed as seconds:frames and animations run at 30 frames per second, so 0:15 indicates ВЅ second.
Move and/or rotate the part to a new orientation. A new track displays in the track list, and a new keyframe displays on the timeline.
Continue moving or rotating parts until you get the desired pose. Whenever you adjust a specific part, a new keyframe displays on the timeline for that part at that specific frame position.
When you’re ready to preview the animation, you can either:
By default, the timeline displays a duration of 1 second (30 frames), but the animation’s actual duration is determined by the final keyframe. To add more time to the timeline, enter a new value in the right-side box of the position indicator.
Keyframes
Once you create basic poses for a rig, fine-tuning individual keyframes can significantly improve the final animation.
Adding Keyframes
Whenever you change a part’s position or orientation, a new keyframe displays on the timeline. You can also add keyframes to a timeline through the following methods.
To add a keyframe for a single part of the rig:
To add a keyframe for multiple parts of the rig:
Note that the keyframes insert at the frame position closest to where you click, not at the position of the scrubber.
Moving Keyframes
You can increase or decrease the amount of time between keyframes by moving either individual keyframes or every keyframe in a frame position.
To move a single keyframe:
Click-and-drag it to a new frame position.
To move every keyframe in a frame position:
Navigate to the timeline and click on the white keyframe in the dark region above the tracks. Every keyframe in the frame position is now surrounded with a blue border.
Click-and-drag it to a new frame position.
Duplicating Keyframes
You can duplicate either a specific keyframe or multiple keyframes for multiple parts into a new position in the timeline. This is particularly useful for when you want to
To duplicate one or more keyframes:
Deleting Keyframes
Looping an Animation
To make an animation automatically loop, navigate to the Media and Playback Controls and click the Looping button.
A looping animation doesn’t interpolate between the final keyframes and first keyframes. To make the animation loop smoothly, duplicating keyframes the first keyframes and use them as the final keyframes.
Setting a Priority
An animation’s priority dictates when it will play in an experience. For example, if you play an animation with a higher priority than another animation that’s already playing, the new animation will override the old.
Developers often use unique animations for different player actions and states, such as a jump or idle animation. In this example, the jump animation should take priority over the idle animation so that a character doesn’t perform both at the same time.
There are four types of priority:
To set an animation to a different priority:
Navigate to the Media and Playback Controls and click the … button. A pop-up menu displays.
Saving an Animation
When you save an animation, Studio saves it as a KeyframeSequence object. This object contains all keyframes for an animation, determines if the animation is looped, and notes its priority against other animations.
To save an animation:
Navigate to the Media and Playback Controls and click the … button. A pop-up menu displays.
Select Save or Save As to save the animation as a child of the AnimSaves object (itself a child of the rig).
Exporting an Animation
When you export an animation to Studio, it becomes available for use in all experiences. This means that you only need to create an animation once, then you can reuse it as many times for as many characters as you want.
To export an animation:
Navigate to the Media and Playback Controls and click the … button. A pop-up menu displays.
In the Asset Configuration dialog, fill out the Title and Description fields.
Click the Submit button.
Defining Important Settings for Default Character Animations
If your animation will be used for a default Roblox character animation like jumping or running, you must rename the final keyframe End (with a capital E ). You can do this by performing the following steps:
Right-click the final white keyframe symbol in the dark region. A pop-up menu displays.
Animation
An object that references an animation asset (AnimationId) which can be loaded by a Humanoid or AnimationController
Should I load an Animation on the client or server?
In order for AnimationTrack|AnimationTracks to replicate correctly, it’s important to know when they should be loaded on the client (via a LocalScript ) or on the server (via a Script ).
If an Animator is a descendant of a Humanoid or AnimationController in a Player’s Player/Character|Character then animations started on that Player’s client will be replicated to the server and other clients.
If the Animator is not a descendant of a player character, its animations must be loaded and started on the server to replicate.
The Animator object must be initially created on the server and replicated to clients for animation replication to work at all. If an Animator is created locally, then AnimationTracks loaded with that Animator will not replicate.
Both Humanoid/LoadAnimation and AnimationController/LoadAnimation will create an Animator if one does not already exist. When calling LoadAnimation from LocalScripts you need to be careful to wait for the Animator to replicate from the server before calling LoadAnimation if you want character animations to replicate. You can do this with WaitForChild(“Animator”).
See also
Properties
AnimationId
This property is the content ID of the animation an Animation object is referencing. Once an animation has been created and uploaded to Roblox the content ID can be found in the uploaded animation’s URL.
Archivable
Determines if an Instance can be cloned using /Instance/Clone or saved to file.
ClassName
A read-only string representing the class this Instance belongs to
DataCost
The cost of saving the instance using data persistence.
A non-unique identifier of the Instance
Parent
Determines the hierarchical parent of the Instance
RobloxLocked
A deprecated property that used to protect CoreGui objects
SourceAssetId
archivable
className
Functions
ClearAllChildren ( )
This function destroys all of an Instance ’s children.
Clone ( )
Create a copy of an object and all its descendants, ignoring objects that are not Instance/Archivable|Archivable
Destroy ( )
Sets the Instance/Parent property to nil, locks the Instance/Parent property, disconnects all connections, and calls Destroy on all children.
FindFirstAncestor ( string name )
Returns the first ancestor of the Instance whose Instance/Name is equal to the given name.
FindFirstAncestorOfClass ( string className )
Returns the first ancestor of the Instance whose Instance/ClassName is equal to the given className.
FindFirstAncestorWhichIsA ( string className )
Returns the first ancestor of the Instance for whom Instance/IsA returns true for the given className.
Returns the first child of the Instance found with the given name.
FindFirstChildOfClass ( string className )
Returns the first child of the Instance whose Instance/ClassName|ClassName is equal to the given className.
Returns the first child of the Instance for whom Instance/IsA returns true for the given className.
FindFirstDescendant ( string name )
GetActor ( )
Returns the Actor associated with the Instance, usually the first Actor ancestor
GetAttribute ( string attribute )
Returns the attribute which has been assigned to the given name
GetAttributeChangedSignal ( string attribute )
Returns an event that fires when the given attribute changes
GetAttributes ( )
Returns a dictionary of string → variant pairs for each of the Instance|Instance’s attributes
GetChildren ( )
Returns an array containing all of the Instance ’s children.
GetDebugId ( int scopeLength )
Returns a coded string of the Instance s DebugId used internally by Roblox.
GetDescendants ( )
Returns an array containing all of the descendants of the instance
GetFullName ( )
Returns a string describing the Instance ’s ancestry.
GetPropertyChangedSignal ( string property )
Get an event that fires when a given property of an object changes.
IsA ( string className )
Returns true if an Instance ’s class matches or inherits from a given class
IsAncestorOf ( Instance descendant )
Returns true if an Instance is an ancestor of the given descendant.
IsDescendantOf ( Instance ancestor )
Returns true if an Instance is a descendant of the given ancestor.
Remove ( )
Sets the object’s Parent to nil, and does the same for all its descendants.
Sets the attribute with the given name to the given value
Returns the child of the Instance with the given name. If the child does not exist, it will yield the current thread until it does.