Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
Model Engine 4 Model Engine 4
  • Project overview
    • Project overview
    • Details
    • Activity
  • Issues 110
    • Issues 110
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Create a new issue
  • Issue Boards
Collapse sidebar
  • MythicCraft
  • Model Engine 4Model Engine 4
  • Wiki
    • Technical
  • Animation Systems

Animation Systems · Changes

Page history
Update Animation-Systems.md authored Sep 28, 2023 by Ticxo's avatar Ticxo
Hide whitespace changes
Inline Side-by-side
Showing with 66 additions and 0 deletions
+66 -0
  • Technical/Animation-Systems.md Technical/Animation-Systems.md +66 -0
  • No files found.
Technical/Animation-Systems.md
View page @ 27990988
Model Engine 4 adds a new animation system that, to put it simply, is a direct upgrade from the previous Priority
System. Hence, it was given a clunky yet precise name: **Priority State-Machine Animation System**.
Although the old system is still usable, we highly recommend switching over to using this new system as it can do
everything the old system does but better and more flexible!
This bakes the question: What was wrong with the old system? A lot, apparently.
## The Problem
Let's do a recap on the old system.
The Priority System relies on 2 very important (but wrong) assumptions:
* That each animation has a distinct priority and will never change
* That interpolating between two animations equates to fading in and out the animations, and adding them together
These assumptions are obviously very wrong. While the first point can be worked around, the second point affects
animation freedom severely, especially on interpolating rotations between two animations. Whenever you see weird
interpolation bugs happening when a model switches between `IDLE` and `WALK` state, that is the doing of the second
assumption.
To understand this problem a little bit better (for academic reasons,) here is a very simple example. If you don't care
about it, first why are you here ?_?, second you can skip to the next part.
Let's say we have a model with an `idle` and `walk` animation, and let's compress the animations down to interpolating
between two values.
| Animation | Value |
|-----------|:-----:|
| default | 1 |
| idle | 0 |
| walk | 0 |
Let's visualize `idle` trying to interpolate into `walk`. Since both animations have the same value `0`, logically
speaking, the value would remain at 0. However, because we assumed that all animations have a defined priority, `walk`
is technically higher priority than `idle`. Furthermore, we also assumed that interpolation is just adding two faded
values, our formula becomes: `lerp(idle, default, progress) + lerp(default, walk, progress)`. Substituting `progress`
with `0.5`, we get `lerp(0, 1, 0.5) + lerp(1, 0, 0.5)`, or `0.5 + 0.5 = 1`. Our interpolation somehow reached `1`.
The astute among you will realize that the culprit comes from the default model value being `1`, because if we set
default to `0` while the two animations to `1`, the formula works out. In fact, the formula functions properly as long
as the default value is `0`. This explains why simple models seldom encounter this, while more complex models that
requires default rotations suffers
greatly.
## The Solution
Don't give animations a priority.
Yep, that's it. At least we are not using animation priorities for interpolations. The new system uses state-machines to
ensure that only one animation is playing at a time, and interpolate animations directly from each other instead of
doing through the default pose first.
However, since the state-machine can only play one animation, this means that animation overlapping is no longer
available: a trait that the priority system allows. This is where we merge the two ideas into one.
Instead of one state-machine per model, each model can have an infinite amount of state-machines, all still limited to
playing only one animation. We then assign priorities to these state-machines, so that the final result of the animation
is computed with the values calculated by the state-machines.
## Conclusion
~~I am a fucking genius.~~
To be fair it took me this long to figure this out, I'm ashamed of thinking the old system is a good idea. But it's
fixed now so woohoo!
\ No newline at end of file
Clone repository
Home
FAQ / Common Issues
Commands & Permissions
Configuration
Modeling
  • Creating a Model
    • Hitbox & Eye Height
    • Shadow
  • Bone Behaviors
  • Animating a Model
  • Importing a Model
  • Scriptable Keyframes
MythicMobs
  • Mechanics: Model
  • Mechanics: VFX
  • Conditions
  • Targeters
API
  • Basic
    • Apply / Remove Model
    • Play / Stop Animation
    • Configure Bone Behaviors
    • Per-Player Model
    • Events
  • Advanced
    • Custom Base Entity
    • Custom Mount Controller
    • Custom Importer
    • Custom Bone Behaviors
    • Custom Script Reader
    • Custom Timeline
    • Custom Animation Handler
    • Custom Render Type
Technical
  • Terminology
  • Animation Systems
  • Mount Controllers