DragonBones / DragonBonesCSharp

DragonBones C# Runtime
MIT License
535 stars 198 forks source link

How to use animation mixing #16

Closed James2022-rgb closed 7 years ago

James2022-rgb commented 7 years ago

Hello, on DragonBones features page, it mentions animation mixing using layers (normal weighting) and groups (additive weighting).

Can someone shed a light on how to use these features ? I do know there are parameters for them in DragonBone.Animation.FadeIn method, but I'm not exactly sure how to use them. Also, I see no option for animation layers or groups in DragonBonesPro Editor.

I'd really appreciate any help, since I'm getting pretty desperate because of lack of documentations. Thanks in advance !

toadietechnika commented 7 years ago

Here you go (The one in Bold-Italic is the parameter, so it's the fourth one. The default layer is 0, so if you play an animation in another layer then it will mix with its other animation layer/s.

DragonBone.Animation.FadeIn( string animationName, float fadeInTime = -1.0f, int playTimes = -1, int layer = 0, string group = null, AnimationFadeOutMode fadeOutMode = AnimationFadeOutMode.SameLayerAndGroup, bool additiveBlending = false, bool displayControl = true, bool pauseFadeOut = true, bool pauseFadeIn = true )

Sample: Armature.Animation.FadeIn("Shoot", 0.05f, -1, 0); // a shooting animation that plays in loop (-1) Armature.Animation.FadeIn("Kick", 0.025f, 0, 1); // while shooting, he also kicks in one round. Not sure if that 0 plays once though, but I hope you get my point :D

James2022-rgb commented 7 years ago

Thank you for your response ! I wasn't expecting to get one this fast.

So that's why I don't see any option for layers in DragonBonesPro Editor. I think I'm getting the hang of it now.

Another question, if I may : Am I correct in thinking there's no way to use different animations for different bones (and not blending them)? For example, I might want to use the animation "walk" when just walking normally, which moves all limbs. But when attacking while walking, I might want to use "walk" on legs but "attack" on arms (which would override the movements "walk" has on arms).

I know this can be done in Unity's 3D Mecanim system, using the Mask mechanism. I also see AddBoneMask(string) method in DragonBones.AnimationState class, but I'm having difficulty figuring out how it works.

Currently I'm using nested armature and layer system (thanks to you!) and so far it's working fairy decently. But it would be nice to know if there's something like Mecanim's Mask system in DragonBones. Thanks in advance :)

toadietechnika commented 7 years ago

Yeah, it's in the codes of Dragon Bones. I've had difficulties too at first because of lacking documentations, fortunately we can also view and analyze their codes and see what they do :D

In response to your question: I haven't tried that, but my guess for now (... and someone would also enlighten me on this if I gave some wrong information haha but anyway - ) is you can't overlap animations that way (of just getting bones from this animation, overriding the other bones of that animation). So I think blending is the only way to achieve that.

That would also depend on the keyframes affecting on the animations. When blending, the bones without keyframes of this animation will affect from the blending animation, otherwise it would mess up (sort of-).

To be honest, I haven't heard of a "Mecanim's Mask System" on Dragonbones so I gotta see what else is there. Glad you're doing well on it, keep it up!

James2022-rgb commented 7 years ago

So, there isn't anything like AvatarMaskin DragonBones animation system (just not yet, I hope !)...

Thank you for your time, I really appreciate it. I might ask another question some time soon, I'd be grateful if I could get your help again :)

Closing now !

PraveenKrishna07 commented 3 years ago

Yeah, it's in the codes of Dragon Bones. I've had difficulties too at first because of lacking documentations, fortunately we can also view and analyze their codes and see what they do :D

In response to your question: I haven't tried that, but my guess for now (... and someone would also enlighten me on this if I gave some wrong information haha but anyway - ) is you can't overlap animations that way (of just getting bones from this animation, overriding the other bones of that animation). So I think blending is the only way to achieve that.

That would also depend on the keyframes affecting on the animations. When blending, the bones without keyframes of this animation will affect from the blending animation, otherwise it would mess up (sort of-).

To be honest, I haven't heard of a "Mecanim's Mask System" on Dragonbones so I gotta see what else is there. Glad you're doing well on it, keep it up!

is there any way to use dragon bones with unity built in animator?