Animate an NPC Using Expression Language and State Transitions
Loading Your Model and Viewing Animations
Import your 3D model (glTF, GLB, OBJ, or Bedrock geo.json) using the built-in model viewer. The viewer displays your character's node hierarchy, helping you understand which bones control which parts. Examine existing animations to see how they're structured.
Setting Up Animation States
In the animation editor, create states for different actions: idle, walk, attack, or custom emotes. Define transitions between states using expression language conditions. For example, transition from idle to walk when the player moves, or idle to attack when a target is nearby.
Writing Trigger Expressions
Use the expression language to bind animations to game events. Reference player position, NPC health, or custom variables to decide which animation plays. The editor provides code hints for available functions and properties.
Server Synchronization
Enable server sync to ensure all players see the same animations at the same time. Test animations in multiplayer to confirm they play consistently across clients.