ENTITY EVENTS DOCUMENTATION
Version: 1.10.0.7

Index

General Notes
Animation Notes
Events
Animation Controller Events
Animation Events
Back to top

General Notes


This document contains details for driving various events via entity .json data. Note that entity events go in behavior packs, and use the same animations and animation controllers setup that are used in resource packs.

Entity events are a way to drive gameplay in the Bedrock engine. These events can typically include slash commands, entity events (e.g. become an adult), and MoLang expressions (e.g. set the MoLang variable "variable.foo" to 3 on a particular entity). Animations and Animation controllers provide a method for driving state machines and timelines for an entity. For example, a particular animation controller could be in a particular state, and running a particular animation, and we want events triggered when entering/exiting that state. Alternately, an "animation" could be running, and we wish to fire off events during that animation. The entity event timeline mechanic makes this possible.
Back to top

Animation Notes


Entity events occur in behavior packs, which execute only on the server. As the server side of the game has no visual aspects to it, obviously no bone-based animations can occur. However, a traditional animation is basically a timeline of events, with the events being bone positions for an animated visual rig that moves the entity's visual shape around. The mechanisms for the Bedrock animation system are state machines (Animation Controllers), and timelines (Animations). These concepts apply directly to the triggering of events, thus the animation system can execute on the server (minus the visual aspects), with the intent of driving entity events.

To use entity events, add animation controllers and animations to a behavior pack just as you would to a resource pack. Add animation and animation controllers to an "animations" section in the description field of an entity. These animations and animation controllers will run on the server just as if they were on the client in a resource pack.



Back to top

Events


Events consist of three categories, all represented by a string:
- Entity events
- Slash Commands
- MoLang Expressions

In detail:

Entity Events: Currently, we only support entity events to self, and these take the form "@s event". These are events declared in the events section of the entity definition file. For example, in the cat.json, "minecraft:ageable_grow_up" event causes the kitten to grow up. This would take the form of "@s minecraft:ageable_grow_up"

Slash commands: Any slash command can be invoked, such as "/particle minecraft:example_smoke_puff ~ ~ ~". The assumed entity for the slash command is the invoking entity, so this particular slash command will spawn a smoke puff effect at the entity's location.

MoLang Expressions: This executes a MoLang expression. The primary usage is to set MoLang variables that can be used later. For example, a state transition might be looking at a particluar MoLang variable, and this expression could change that variable. A particle effect on the entity might change color due to MoLang variables that the effect uses for color tints.
Back to top

Animation Controller Events


Animation controllers can trigger events on entry or exit of a state. Events to trigger on state entry go in the "on_entry" section, those on exit go in the "on_exit" section.



Back to top

Animation Events


Animations can have a timeline dedicated to events. The "timeline" section contains the event timeline list. Below there are various examples where particular times can trigger a single event, or an array of events:



Back to top