Animations
Model Entities, which are entities that have a modelUri
when created, can have their in-game animation state completely controlled and blended using the Entity animation methods.
Animations do not work with Block Entities.
GLTF Animations
The HYTOPIA SDK expects all possible animations of a model to be included in a model's .gltf file. Model animations are referenced by their name. For example, if your .gltf file has an animation called idle
that you want to play and loop as soon as an entity spawns, you'd do that as follows:
Types Of Animations
HYTOPIA currently supports two types of animations.
Looped Animations - These are animations that will contiue to play over and over again from start to finish in a smooth manner until they are explicitly stopped.
One-shot Animations - These are animations that will play from start to finish only once, or until they are explicitly stopped or restarted.
Animation Blending & Playback
At this time, all played animations for a model entity are equally blended in the visual playback state of the entity in game. This means you can play multiple GLTF model animations at the same time and they will blend equally between the same model node that may be involved in multiple playing animations.
Starting And Stopping Animations
For model entities, we can easily start, stop and filter the played animations of an entity. Here's an example of how our DefaultCharacterController internally handles animation state changes based on player inputs.
Animation state is internally tracked - so invoking start or stop of animations that are in an irrelevant state won't cause unusual animation states or performance overhead.
One-shot Animations
One-shot animations are exactly what they sound like. An animation that plays only once. This is great for things like a gun-shooting effect when the player presses a button in game to fire a weapon, or a movement of a player's hand each time they click to interact with something, etc.
Let's assume our PlayerEntity model assigned to a player when they join a game has a dance
animation, and a hand waving animation called wave
. We'll play then as a one-shot when a player joins.
Animations & Entity Colliders
It's important to note that the animation state of model entities is entirely visual. Played animations will not automatically alter or move the collider(s) of an entity even if the entity is visually moving relative to it's collider because of the animation.
If you need your collider to move along with the animation state played, you'll need to implement this manually with your own timings and logic to alter the translation and rotation of the entity collider(s) relative to the animation played.
Last updated