Jump to content

How to blend animations?


ozRocker
 Share

Recommended Posts

I'm using preview version 2.4 to try and get animation blending happening.  I've checked the playground and also the tutorial but I still don't understand how to apply it to my character animations.

My character moves like this:

avatar.skeleton.beginAnimation("Idle",true,1);

//some stuff

avatar.skeleton.beginAnimation("Walk",true,1);

I don't know where to apply "enableBlending" and "blendingSpeed" to this.  Does anyone know?

Link to comment
Share on other sites

7 hours ago, Deltakosh said:

Hello

to enable blending, just go through skeleton's animations like this:


avatar.skeleton.animations.forEach(function(animation) {
   animation.enableBlending = true;
   animation.blendingSpeed = 0.05;
});

 

My skeleton doesn't have an "animations" property.  This spits out an error saying its undefined.

This is what my "skeleton" object looks like:

babylonjs_animation.png

Link to comment
Share on other sites

13 hours ago, Deltakosh said:

Sorry I'm stupid:


avatar.skeleton.bones.forEach(function(bone) {
   bone.animations.forEach(function(animation) {
      animation.enableBlending = true;
      animation.blendingSpeed = 0.05;
   });
});

 

I'm not able to do this :/  I get "Uncaught TypeError: Cannot read property '0' of undefined" when trying to change the "enableBlending" property.

On further inspection via developer tools I can see "blendingSpeed" is initially 0.01 but "enableBlending" is set to "undefined".

Link to comment
Share on other sites

hi @ozRocker, I have a simple test and facing same problem.

https://dl.dropboxusercontent.com/u/86585940/babylon-dance/index.html

I did export 3d model and animation (babylon format) from 3d Max, it contain two animation dance, I'm making it turn cycle after each 5 sec, til now it work, but not blending (smooth change). My main code below:

            // set blending enable for each bone animation
            skeleton.bones.forEach(function(bone) {
			   bone.animations.forEach(function(animation) {
				  animation.enableBlending = true;
				  animation.blendingSpeed = 0.01;
			   });
			});
			//console.log(skeleton);
			
			skeleton.createAnimationRange("dance1",0,300); //  define dance 1 animation
			skeleton.createAnimationRange("dance2",450,560); //  define dance 2 animation
			skeleton.beginAnimation("dance1",true,1); // play the first one
			
         
            // change animation dance each 5 secs
            window.setInterval(function(){
				if(currentDance=="dance1"){
					currentDance = "dance2";
				}else{
					currentDance = "dance1";
				}
				girl.skeleton.beginAnimation(currentDance,true,1);
				},5000);

I used to check your Playground sample but it is just black screen, so I wonder how you success. Can you point me?

SOrry for my poor English.   

 

Link to comment
Share on other sites

3 minutes ago, tranlong021988 said:

I used to check your Playground sample but it is just black screen, so I wonder how you success. Can you point me?

I get a black screen because this line:

animation.enableBlending = true;

gives me an error and breaks the code.

If I remove that line then the code will run, but there is no animation blending.  I'm still stuck, sorry!

Link to comment
Share on other sites

3 minutes ago, ozRocker said:

I get a black screen because this line:


animation.enableBlending = true;

gives me an error and breaks the code.

If I remove that line then the code will run, but there is no animation blending.  I'm still stuck, sorry!

That so sad, I dig around and see that it's not too many success case, this is what I find out (may be the best):

 And @RalphEl have a create contribution here: 

But I don't know how to make it work with my case. 

Link to comment
Share on other sites

Oz, I've been keeping an eye on this thread, and I have just tried your playground example above. When I disable the blending code, I see "Josh" cycle through the animations BUT this error, at line 44,  is being thrown repeatedly in my FF web console"

Quote

TypeError: avatar.skeleton is null

There also seems to be oddities in the debug layer values (eg. Total Textures = 0, when Josh  obviously has a texture)

Not sure what it all means though :(

cheers, gryff :)

Link to comment
Share on other sites

yeh, I can see its spitting out

VM118:47 Uncaught TypeError: Cannot read property 'beginAnimation' of null

for me too.  Same as the other playground in my other thread.  But the playground still runs, so the mesh obviously must have a skeleton and animations.  Also, I don't get these errors in my production environment.

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...