Animation
This section provides guidance for setting up custom animations on entities. These are animations that transform some element of the entity over time, such as position, scale, or a property of some component on the entity. Note: This section deals with creating animations in Studio and working with Studio’s core animation system–if you’re looking for guidance on working with a GLTF model file's built-in animations see the 3D Models section.
Components are provided for procedural animation, and can be split into two kinds:
- Transitions
- Relationships
Animations can be added to the entity via the editor or in code. Adding them in the editor is done via the "New Component" button:
Animations can also be added via code, using the component’s import name.
Transition animations
These animations transition an object from one state to another over time. There will be a 'from' and 'to' state, and the animation can either finish or be set to loop.
Editor Name | ecs Import Name | Description | Event when Complete |
---|---|---|---|
Custom Property Animation | CustomPropertyAnimation | Animate a single number property on the attributes of a target object | animation-complete |
Position Animation | PositionAnimation | Animate the position of a target object | position-animation-complete |
Scale Animation | ScaleAnimation | Animate the scale vector of a target object | scale-animation-complete |
Rotate Animation | RotateAnimation | Animate the rotation of a target object | rotate-animation-complete |
Custom Vec3 Animation | CustomVec3Animation | Animate the named 3D vector attribute on a target object | vector-3-animation-complete |
Properties on transition animations
Property | Data | Component | Description |
---|---|---|---|
attribute | String | Custom Property Animation, Custom Vec3 Animation | Selected attribute to animate (e.g. position, scale, material) |
property | String | Custom Property Animation | Individual property to animate (e.g. x, y, or z for a vector attribute) |
target (optional) | Drop-down list of all objects in the hierarchy | All | The target object to animate. If 'none' selected then animation is run on the object that the component is attached to. |
from/from(x, y, z) | Number or 3D vector | All | The starting state of the animation. |
to/to(x, y,z) | Number or 3D vector | All | The ending state of the animation. |
autoFrom | Checkbox | All | If enabled, ignore 'from' property and animate from the state of the object at the start of the animation. |
duration | Number, in milliseconds | All | Length of time that the animation runs. |
loop | Checkbox | All | If enabled, repeat the animation. |
reverse | Checkbox | All | Whether to play in reverse, if loop set. |
easeIn | Checkbox | All | If enabled, easing function will be applied over time instead of straight interpolation (quadratic by default) |
easeOut | Checkbox | All | If enabled, easing function will be applied over time instead of straight interpolation (quadratic by default) |
easingFunction | Name of easing to apply | All | Easing options: Quadratic (default), Cubic, Quartic, Quintic, Sinusoidal, Exponential, Circular, Elastic, Back, Bounce |
Relationship animations
These are animations that express a relationship between an object and a target. When running, they maintain that relationship for the object that they are attached to.
Editor Name | ecs Import Name | Description |
---|---|---|
Follow Animation FollowAnimation | Follow a target object at the given distance. | |
Look At Animation | LookAtAnimation | Maintain orientation to face a given target or point. |
Properties on relationship animations
Property | Data | Component | Description |
---|---|---|---|
target Drop-down list of all objects in the hierarchy | All | The target object to track when animating. If 'none' selected then animation is disabled. | |
minDistance | Distance in meters | follow-animation | Minimum distance to maintain when following. |
maxDistance | Distance in meters | follow-animation | Maximum distance to maintain when following. |
elasticity | Number between 0-1 | follow-animation | Proportion of distance to move (per second) when target is outside of min/max distance (0 never moves, 1 is instantaneous) |
target(x, y, z) | 3D vector | look-at-animation | Target position to track when animating (if no target object set). |