Jump to content

Animation weights


GameMonetize
 Share

Recommended Posts

Hey team!

@MackeyK24 asked for it with so much energy that I spent my entire week end working on a new feature: the animation weights support

To learn more about it, please read the doc here: http://doc.babylonjs.com/babylon101/animations#animation-weights

A demo can be found here: https://www.babylonjs-playground.com/#IQN716#3 

ANIMATION WEIGHTS

As always, any feedback is welcome!

 

Note: I could have added a third animation to the demo (a run animation) but the model animation for run is a bit bad (it looked like the model was flying). If you have a better model, feel free to let me know

Link to comment
Share on other sites

52 minutes ago, Dad72 said:

It looks cool, I'll test that soon. So we can made walk a character and play a second animation of shooting for example?

Thank you Dk for that.

Yes and no... You can BLEND similar  animations like your ground locomotions. This blend ALL the bones and play weighted animations on ALL the bones.

Our next setup would be to create some kind of BONE MASKING system we could them implement LAYERS so you play then base animations and blend in the TOP HALF of body masked of and play either a blend or a total weight of 1.0  to top half of body bones. IE ... Walk or running while swinging a sword or shooting weapon.

This is how unity does it and how i will capturing the Animation Controller Layers as metadata and not only blend the ground locomotion animation but also apply any LAYER animations that should be running based on the Animation State Machine. Exactly how unity does it. That way you can use the Unity Editor to setup all the animations (or use existing animation controllers from the asset store something).  At least that is my goal for the babylon toolkit :)

 

Link to comment
Share on other sites

Yo @Deltakosh I need some advice....

Using the new animation weight system from a Unity Controller Blend Tree... Often each BlendTree may have up to 16 or more BlendTree Branches (The bendable animations that I loop thru calling scene.beginWeightedAnimation). Now that thechnically starts running all 16 or more animations. The first one has a full weight of 1.0 and the other fifteen are at ZERO. Then in the game loop I would loop thru the returned BABYLON.IAnimatable[] array and change each weight according to which ones should actually be contributing a weight GREATER than ZERO. I cant see how that would be no more than 2 or 3 animations out of the 16 that actually get used depending on your input values... Like gamepad stick forward.

Should I:

A... Just load all 16 or more animations for blending and just live with the performance cost of the dozen or more animations that are not getting used (at least for that update frame check) but actually still playing the animation as far as the engine is concerned.

B... Figure out which few of the 16 animations SHOULD be contributing on that frame and if those animations are NOT currently playing... call scene.beginWeightAnimation from that frame update with ONLY the few animations that should be contributing. But this too has a performance cost as well . Especially if the user is doing ALOT of gamepad stick movement. Could be calling beginWeightAnimation every few frames.

C... Load all 16 by calling scene.beginWeightedAnimation. Then immediately STOP all of them. Then in the frame update figure out what ones should contribute weight, assign the weights accordingly and then figure out what frame we should be on and then each animatable.goToFrame (so timing still in sync)  and finally animatable.restart on the ones that SHOULD be contributing.

I dont know about what kind of performance cost constantly STOPPING and RESTART the weighted animations that should be contributing VS Loading them all and just changing the weights on 16 currently blendable playing animations VS constantly scene.beginWeightAnimation with only the few animations that should contribute on that frame.

 What do you think ???

Do have any other suggestions on how to handle this ???

 

Link to comment
Share on other sites

I would recommend to keep the number of animations to the lowest level possible.

You can use stopAnimation(target, name) to hand pick which animations to stop

But I have a good news for you: The new version will ignore all animations with weight = 0; So your point A should be fine

 

Link to comment
Share on other sites

2 hours ago, Deltakosh said:

I would recommend to keep the number of animations to the lowest level possible.

You can use stopAnimation(target, name) to hand pick which animations to stop

But I have a good news for you: The new version will ignore all animations with weight = 0; So your point A should be fine

 

Sweet... cant wait for the next commit.... Thanks @Deltakosh ... You da man :)

 

Link to comment
Share on other sites

  • 3 weeks later...

Yo @Deltakosh  and anyone who is interested in Animation Blending.

This is my first little demo of my Frame By Frame Animation State Machine. That Supports Animation Blending (Both Blending Speed And Final Composition)

Note the Play Blend button with play a Walk Forward animation with a 50% blend of the Left Strafe Walk ... Giving a Diagonal Walk Forward result :)

Clear your browser cache and take a look: http://mackey.cloud/games/tester/

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...