Topic category: User side tutorials
First, I set the entity health to 800 (Really high number used for the death animation)
then, when the entity is spawned, it's health is set to 50 (The actual health of the mob)
Then, take a look at this procedure:
The most important part here, is detecting when the mob is moving, and playing an animation along it
The timer lets us set when we want the animation to start. Otherwise, it would just be constantly restarting.
Then, if you take a look at the entire procedure, you will see that even though the mob has 800 health, I reduce it to 50 when it spawns. This 50 is the true health of the mob. We use procedures to detect if the entity is in the dying state. Whenever it is below 15 health, or above 200 health, it is considered to be in dying state. When the entity enters the dying state (AKA: It reaches below 15 health) It starts the dying animation, doesn't play a walking animation because that animation only plays between 16 and 200 health, and heals back to 800 to not be killed while doing the animation. During the dying state, the mob suffers two potion effects: Slowness, and killerpot. Killerpot is a custom potion I made, that makes it so when the effect runs out, the entity despawns. The duration of the effect has to be set by you, and it has to be equal to the duration of the death animation.
Here is a video I recorded of the cyclops dying:
And here is an example of a poorly timed death animation:
In the workspace, there is also an example of a monk playing with a bongo, but that's a bit too complex to explain in just this mini tutorial. If any of you have any doubts, let me know. If you have any bugs in general with the geckolib plugin, I will see if I can help you.