GeckoLib

GeckoLib

146M Downloads

Code LoopType does not Override Json LoopTypes

Nyfaria opened this issue ยท 2 comments

commented

When you playAnim in code using a different LoopType than the Json provides, it does not override it and will just use the Json looptype.

commented

Unable to replicate

Video below of the example creeper having its walk and idle animations overridden with hold on last frame in 1.20.2 4.2.3

You may need to be more specific about version or circumstance?

20-20_175.mp4

image

commented

Ok so after talking with you further I found the issue

Basically - this has nothing to do with overriding the loop type.

What's happening is that the animation system doesn't try to loop your animation until it knows it's done.
It does this by grabbing the animation length property in your animation json, and storing that.
If it can't find one, it tries to determine it by using the highest-time keyframe your animation has defined.

If none of your keyframes are defined by time (I.E. they're all just molang based), then the system can't tell how long your animation is - so to prevent it from early-terminating, it assumes it's an indefinite animation.

There is really no good way to solve this from Geckolib's side, as I can only come up with the following two possible solutions:

  1. Make every animation just end after 10 seconds (or some other predetermined length of time). This doesn't really.. solve.. anything, except for preventing excessively long locked loops - but that doesn't really mean much/anything. It also introduces significant problems elsewhere.
  2. Try to brute-force determine the length of the animation via making the animation compute a resultant position/rotation/scale for every tick up to a pre-determined amount, then see if a pattern emerges, then call that the loop point. This will still fail on even the most modest molang-based animations however, and would significantly increase boot time.

Obviously, neither of these work.

Therefore, the best solution to this, is to just.. put an animation length on your animation.
That's it - that's all you need to do lol