KybernetikGames / animancer

Documentation for the Animancer Unity Plugin.
64 stars 8 forks source link

Animation Events inside AnimationClips keep being fired when animation clips are not played. #131

Closed tatoforever closed 3 years ago

tatoforever commented 3 years ago

Environment

Description

Animation Events inside AnimationClips keep being fired when animation clips are not played. Tested on LinearMixerTransitions only.

Reproduction

Steps to reproduce the bug:

I understand that events should play when the animations in the Mixer are being mixed/play but if an animation has 0 weight, none of his events should be fired, this issue cause an explosion of hidden events being fired when animations aren't playing.

tatoforever commented 3 years ago

image This is the AnimancerComponent in question, you can see that Walk and Run animations has a weight of 0 but all their footstep sounds are still playing when Idle is playing.

KybernetikGames commented 3 years ago

Actually, those weights are showing in italics which indicates that they're not exactly 0. If you click on the foldout arrow next to the states you can see their full weight.

Most likely, that means you're not setting the parameter to actually 0 so check the code you're using to control it.

Also, what if instead of just using italics when the value rounds to 0.0 or 1.0 I change it to show as ~0 or ~1. Do you think that would make it clearer that it's an approximation or would people get confused and read it as -0 and -1?

tatoforever commented 3 years ago

Hi, You where right, after further inspection, debugging the Parameter value it was spitting some really low value (0.0000x). Not enough to interpolate to the walk/run animations but enough to fire their events because still somehow bigger than zero. I'm clamping the value now (if below 0.005f set it to 0f) and it fixes the issue. However is kinda confusing that the state inspector shows 0.0 when is not exactly zero. Is a very low value close to zero. I would suggest to add some scientific notation or just output the raw value (I believe Unity will convert it to scientific notation once it becomes very small). As for approximating 1.0, either ~ or scientific notation should do the job. Or simply add both values, one next to each other, the raw value and the clamped approximated value (~0.0 to ~1.0). Side note, with Animancer I was able to create characters controllers so complex (with ease) that I don't believe i would be possible to do it with Mecanim. Here is an example of this powerful system put into action (all characters are using Animancer controllers and all the AI characters are using the same controller): https://youtu.be/xRGLd4qdG_k https://youtu.be/BKxsjK-Qp_0 https://youtu.be/sDhas41jw2Y One thing that would be great is to being able to play a set of animations one after the other without having to check animations weights/time/set events. Something like this: animancer.Play(anim1, anim2, anim3, , 0.5f, FadeMode.FixedDuration); // or like this animancer.Play(arrayOfAnimsAsset, 0.5f, FadeMode.FixedDuration);

KybernetikGames commented 3 years ago

It would use scientific notation if I let it, but I didn't want to take up that much screen space on every line for such finicky specific numbers in an Inspector where lots of stuff is already going on in real time. I was hoping the fact that it always shows 2 digits would make it obvious enough that it will often only be an approximation (with italics indicating when it actually is one) and you can expand the foldout if you want to see the proper weight with all the other details.

Though now that I've made the green time bar scale vertically in proportion to the weight, it might not even be necessary to show a number there at all. That would have actually made the problem really obvious if we just looked at that instead of being distracted by the numbers.

animancer.Play(arrayOfAnimsAsset, 0.5f, FadeMode.FixedDuration);

Take a look at the ClipTransitionSequence script.

tatoforever commented 3 years ago

Take a look at the ClipTransitionSequence script.

Great, that should do the trick. I was basically doing the same but having one class that abstract all the clip addition and events makes code smaller. Last thing, if not already in your plans, make a ClipTransitionSequence scriptable asset, so we can set them separately from prefabs and play them at runtime like other mixer/transition assets. Let me know if I need to create a feature request for this. Awesome support.

KybernetikGames commented 3 years ago

In general, a separate feature request would be better so I can keep track of things more easily (particularly for suggestions that I don't implement right away).

But for this, take a look at this post I just made.

tatoforever commented 3 years ago

Perfect thanks again!