Animations and animation controllers
Concept
An animation is a keyframe file that changes the rotation, position and scale of bones over time (animations/*.json). An animation controller (AC) is a state machine. Each state decides "what to play now" and "under what condition to move to another state". Controllers exist in both the resource pack (RP) and the behavior pack (BP). RP controllers play bone animations, sounds and particles, and BP controllers run commands, events and Molang expressions (Source: bedrock-wiki animation-controllers/animation-controllers-intro).
A state machine is in only one state at a time. Every tick the controller (1) plays the current state's animations and runs on_entry commands (if it just entered), and (2) checks transitions from top to bottom, moves to the first one that is true, and runs on_exit. So it changes state at most once per tick. If there is no initial_state, it uses a state named default, and if that is missing too, it is a content log error. When the entity is reloaded (player join and leave, chunk reload), the controller returns to the default state, so put logic in the default state that restarts the key animations.
Example: two states, ground and flying
Excerpt: Intro to Animation Controllers · docs/animation-controllers/animation-controllers-intro.md · Bedrock Wiki · License CC BY 4.0 (docs/licenses/CC-BY-4.0.md in the repository) · Commit 0930b39{"format_version": "1.10.0","animation_controllers": {"controller.animation.helicopter.blade": {"initial_state": "ground","states": {"ground": {"transitions": [ { "flying": "!q.is_on_ground" } ]},"flying": {"animations": ["flying"],"transitions": [ { "ground": "q.is_on_ground" } ]}}}}}
A controller does nothing just by being defined in a file. You must give it a short name in the client entity's animations and run it in scripts.animate. If you attach a condition, it runs only when that expression is true.
"description": {
"identifier": "wiki:helicopter",
"animations": {
"blade_controller": "controller.animation.helicopter.blade",
"flying": "animation.helicopter.flying"
},
"scripts": {
"animate": [ { "blade_controller": "q.has_rider" } ]
}
}
A state of an RP controller also plays sounds and particles. First define sound_effects and particle_effects short names in the client entity and call them from the state with effect (you can also give a locator). Not every particle works here, so if there is a problem, try another particle (for example one that the blaze controller uses) (Source: bedrock-wiki).
"explode_state": {
"sound_effects": [ { "effect": "explosion" } ],
"particle_effects": [ { "effect": "fuse_lit" } ],
"transitions": [ { "default": "q.mark_variant == 0" } ]
}
A BP controller puts slash commands (/say hi), entity events (@s wiki:transform_into_plane) and Molang expressions (v.tickets += 1;) in on_entry and on_exit. The rules below are community research results (Source: private research).
Client entity linking
- In client entities of 1.10.0 and above, put animations and controllers in
animationswith short names and reference them inscripts.animate. If not in the list, they do not run.{community confirmed} - The
animation_controllersarray is for 1.8.0 only, so mixing them makes the entity disappear and gives "client_entity child 'animation controllers' not valid there". "animate": {"controller": {}}or" controller "(with spaces) gives "unknown child schema option type. Allowed types: 'molang'".- If mobs and spawn eggs are not visible right after adding an animation, it is usually broken client entity JSON. Check the content log (Settings, Creator, Content Log GUI), and if you edited by hand, export again from Blockbench. Update a 1.8 client entity to 1.10.0, including its controllers.
Naming rules
- The animation id inside a file must be in the
animation.nameformat ("child pose_1 not valid here" was fixed by changing it toanimation.pose_1). - Write animation, model and bone names in lowercase without spaces.
animation.unwfoxyfm.showtimeworks, whileanimation.UnwFoxy FM.Showtimeand the bone groupRight Eyelidbroke in the game. - If two controllers or files use the same identifier, you get "detected loop in animation controller creation... controller already exists".
- Blockbench export is the Animation tab, file, export, and goes in RP
animations/. Bridge cannot preview animations, so set up controllers by hand.
Idle and walk transitions
- In a controller with
defaultandmovingstates, transition withquery.ground_speed > 0.1(orquery.is_moving) and list the animations inside the state. One controller with several states is better than one controller per animation. q.is_moving && !q.is_swimming && !q.is_sprinting && q.is_on_groundcan be simplified toquery.ground_speed > 0.1 && query.is_on_ground.query.ground_speedis speed, not direction, so usequery.movement_directionfor forward and backward.- If the walk animation lingers for a while after stopping, give the transition back to idle a threshold such as
"idle": "q.ground_speed < 0.2". Putting"override_previous_animation": trueon the idle animation only played idle over walk.
Attacking and walking at the same time
- Put walking in
scripts.animate({"walk":"q.ground_speed"}) or run two controllers in parallel ("animate": ["controller1","controller2"]).override_previous_animationaffects blending. - Attack detection is
variable.attack_time > 0(anywhere: animations, controllers, attachables, client entities) andvariable.has_target.query.is_delayed_attackingstays true during thedelayed_attackpreparation, so use it for long attack animations (v.attack_timeis about 0.2 seconds), and for random attacks give each animation a number, as inmath.random_integer(1, 5) == 1 && query.is_delayed_attacking. Bow draw isquery.main_hand_item_use_duration.
Transition after playing once
- Use
q.all_animations_finishedand put an idle loop state third so it does not repeat immediately. - A toggle such as a lever uses the states
up,down,pull_upandpull_downandq.property(...)transitions.q.all_animations_finishedcaused a one-frame flicker, andq.anim_time > Nworked better.
Holding the last frame and flicker
- hold-on-last-frame is unstable. There is a report that making the last keyframe of every bone linear works, and
loop: "hold_on_last_frame"keeps the last pose. - If a loop animation pops to the default pose at the end, make the first and last keyframes equal (the bone must return to the starting pose) and make the last keyframe linear, not smooth.
- If there is a gap between states, the same flicker occurs in controller transitions, so check that the idle end pose and the attack end pose are the same.
- With no keyframe at the last timestamp, the entity vanished during a lying-down loop. Add the same keyframe at
animation_length. - Smooth keyframes must be wrapped before and after by linear keyframes to avoid glitches in the game (at least a linear frame at 0 0 0).
Molang expression animation
An example that gives a random size per spawn. ?? is null coalescing and ; separates statements.
"scale": "v.size = v.size ?? math.random_integer(1,10); v.anim_time = v.anim_time ?? 0; v.scale = v.size*math.sin(math.min(v.anim_time,3)*30); v.anim_time = v.anim_time + q.delta_time; return v.scale;"
pre_animationruns every render frame. A value increased without multiplying byq.delta_time, as inv.acc = v.acc + 1;, grew about 3.5 times faster thanq.life_time * 60at around 216fps, so multiply values that should follow time byq.delta_time(measurement record, 2026-11-19 Windows 1.26.65.1).- The blend weight in a controller state is not clamped above 1. A 20 degree z-axis animation played with weights 0, 1, 2 and 3 tilted about 0, 20, 40 and 60 degrees, so the amplitude was in proportion to the weight (same measurement).
- If the timer does not advance, use
q.delta_timeinstead ofq.anim_time./playanimationis hardly usable for random sizes, so define it in the client entity'sanimationsandscripts.animate. - Breathing idle: Put
math.cos(query.life_time * 120) * 10(speed 120, amplitude 10) in a separate loop animation and separate it from the limb animations. - Animation speed:
anim_time_update: "query.anim_time + query.delta_time * 1.05"(query.ground_speedis possible instead of a constant). - Molang has no
%("unrecognized token %"). Usemath.mod(a, b). The client tokenizer's token table of 109 entries has no%,^, single&, single|,~or**, and it hasmath.mod. A token not in the table is rejected withunrecognized token: %s{code}. The same table hasloop,for_each,break,continue,return,this,->,array.and[], so these are tokens the client reads{code}. - Seamless rotation: Use
math.mod(query.anim_time * 360, 360)on one Y rotation keyframe (720 to make it faster). A keyframe loop going from 0 to 360 jumps because the end and start angles differ. - Property-based smooth bone rotation: In pre-animation get
t.old_rotationwithq.bone_orientation_trs(bone)(needsqueryable_geometry, a special coordinate system) and usev.rotation = math.lerprotate(t.old_rotation, q.property('pack:rotation_y'), q.delta_time). The property range is 0~360.q.bone_orientation_trs().r.yis limited to -90~90 (Euler), so a full 360-degree rotation also needs z changed. - Random
loop_delay: Aloop_delayusing a random variable becomes random only once after an update. Alternatives areoverride_previous_animationwith a longeranimation_length, or causing a flicker with a random loop timer in the behavior. - Easing and snapping: Per-axis easing within one bone channel is not supported. If Blockbench keyframes snap to 0.833 and so on, change the animation snap setting (double-click the animation). In humanoid animations, position keyframes on the head and arms break the pose, so delete position keys.
Spawn animation and commands
- There is no "just spawned" query, so run
/playanimationfrom the BP entity'son_spawnevent (or the scriptentitySpawnafter event). - Event and command timelines inside a controller may not run, so put the command in a BP animation timeline:
"timeline": {"0.0": ["/playanimation @s animation.x"]}. - RP controllers cannot run
/scripteventor commands, while BP animations and controllers can. - Play delayed repeating sounds inside a looping BP animation and turn them on and off with a controller. The problem where events of a 0.59-second looping attack animation did not run was fixed with
loop: true. - Careless use of
/playanimationkeeps creating new animation controllers on the player and leaks memory.
Variables that read a property
- Use
v.x = query.property('ns:prop')inscripts.pre_animation; the property needsclient_sync: trueand the id uses:, not.. - The
variable.melee_spear_equipped"unknown variable" is fixed with"scripts": {"initialize": ["variable.melee_spear_equipped = 0.0;"]}. Example fix for the error of a player with no spear:"v.melee_spear_equipped = query.equipped_item_any_tag('slot.weapon.mainhand', 'minecraft:is_spear');". - If the modified vanilla player controller and entity do not match the version of others, you get missing-item errors for
first_person_melee_spear_controllerandswimming.no_right_arm. Use the latest vanillaplayer.jsonfrom bedrock-samples. q.above_top_solidworks only in a world generation context ("Failed to resolve query"), andquery.scoreboardcannot be used in a resource pack.- Gating of deprecated queries
{code}: queries that have alast_versionin the official list, such asquery.dash_cooldown_progress,query.is_rising,query.block_propertyandquery.has_block_property, are still registered in the client. The lookup is gated not by the pack'smin_engine_versionbut by the Molang version number the parser receives. A query name can have several version-range entries, and the first entry whose range contains the parser version and whose required experiment toggles are on is used. If no entry matches,Failed to resolve query %s. Either the query does not exist or it is not supported in this context.appears. So a missing query and an out-of-range query give the same error, andunrecognized tokenis a separate error for text that is not in the token table. Whether the Molang version number comes from the pack'smin_engine_version, the file'sformat_versionor another value, and how it maps to game versions, were not found (unknown). Which pack settings block such a query cannot be settled. t.temporary variables leak between the player and attachable animations and reset on lag. Pin them likev.x = (v.x == 1) ? 1 : (t.x ?? 0)and use the leak only to send data (MCPE-240457).
Rotation
- Facing the target (projectile pitch, yaw): Use
"rotation": ["query.target_x_rotation","query.target_y_rotation",0]on the bone (copyarrow.animation.jsonfor arrows). There is a report thattarget_y_rotationdid not work in some cases, and rotating by animation to match the player rotation is wrong, so set the entity rotation in the BP. q.target_y_rotationis roughlyq.head_y_rotation(0) - q.body_y_rotation. In player first person,query.camera_rotation,target_x_rotationandtarget_y_rotationare 0 (MCPE-219473).variable.player_x_rotationworks only for pitch. A workaround is to read the pause menu paper doll camera query and pass it via a temp variable leak.query.vertical_speed*-12is also an alternative for projectile tilt.- Fixing the visual rotation of a mount: after an
-q.body_y_rotationanimation, compute directly withquery.movement_direction,q.positionand trigonometry (a problem if the seat is not the rotation origin). Rotating part of the body independently withrotation.y = -q.body_y_rotationwas unstable. - If the head does not turn in a cutscene, apply the same rotation as the root to the head bone as well. A scale given to the body root by
playanimationdoes not affect the head, so set it on the head separately. - The dolphin-style swim direction is an animation expression, not a component (
dolphin.animation.jsonin bedrock-samples).
Expression techniques
- Bedrock entity animation has no camera animation.
- Stretching a wing membrane: Make a curved mesh, put the origin at the end point, and stretch with bone scale.
- Facial expressions are made with texture swaps or with expression models hidden by scale 0.
- Long Molang keyframes and flipbook animations slow down the Blockbench editor. For Blockbench animation tips, see Modeling and texture tools.
First-person animation
- Vanilla flat items do not react to animation in first person (only 3D geometry attachables such as the spear, trident and shield). Third person works.
- An animation played by an attachable affects only the attachable, so animate the player with
player.entity.json. A first-person-only animation needs its own first-person controller entry. - There is a case where paper doll rendering (
v.is_paperdoll) caused a crash when opening the pause screen.
Armor stand and other queries
- Copy
armor_stand.animation.jsonfrom bedrock-samples for the armor stand and reference it from the entity'sanimationsandscripts.animate. Poses are hard-coded in runtime identifier variables (12~13), so to add poses use your own entity with apose_indexproperty. - Name-dependent animation is
q.is_name_any('steve','alex'). In a case wherequery.is_name_any('Alex')in a controller transition did not run, the transition expression ended with;. - Showing a bone by whether it is equipped: a
1*(query.is_item_equipped(0)||query.is_item_equipped(1))scale.
| id | Source | License | Commit | Accessed |
|---|---|---|---|---|
private-research | Private research (-) | - | 2026-11-13 | |
bedrock-wiki | Bedrock Wiki | CC BY 4.0 (docs/licenses/CC-BY-4.0.md in the repository) | 0930b39 | 2026-11-13 |
ms-learn | Minecraft Creator documentation (Microsoft Learn) | CC BY 4.0 (documentation), MIT (code) | a9fd1c0 | 2026-11-13 |