Jump to content

Animations max number


MarianG
 Share

Recommended Posts

Hi guys, 

I have another little problem. Unfortunately I can't share too much code, but i 'll try to synthesize.

 

I have a park with 7,8 animals, all animals have plenty animations like,  from key 0 to 100 - walk animation, 110-180- run, etc.

 

When I load all animals, I try to start for each of them one animation, random from the entire film.

But animation start only for 3 or 4, when one is finished, start another animation, and so on, but after a few time the animations stop at a time.

And the others animals nothing do.

If i refresh the page, 3 other animals will be animated, and the others nothing, and so on.

I test the animations foreach individual animals, and works fine, but when I import more than 3 or 4 diferent animals the animation not start at all. And all animals have the same skeleton.

 And I can't explain why.

 

 

And a piece of code:

BABYLON.SceneLoader.ImportMesh("",url,"lion.babylon", scene, function (m, p, s) { m[0].active_animation = 1; m[0].skeleton = s[0];  var on_end = function(){     //stop actual animation     scene.stopAnimation(m[0].skeleton, setting[m[0].active_animation].from, setting[m[0].active_animation].to, false,1);     //choose one animation random from film     m[0].active_animation = parseInt((Math.random() * 10) + 1);     //start new animation     scene.beginAnimation(m[0].skeleton, setting[m[0].active_animation].from, setting[m[0].active_animation].to, false,1,on_end);  }  scene.beginAnimation(m[0].skeleton, setting[m[0].active_animation].from, setting[m[0].active_animation].to, false,1,on_end);});

Thanks a lot, and sorry my bad english.

Link to comment
Share on other sites

Hi,

 

would be great to have this reproduced on the playground to be able to debug this. Can you try adding a bit mroe of the original code to playground?

 

A quick note about your code - 

Calling the function at the end of the animation is explicitly running it after the animation stopped. So there is no reason to call stopAnimation. In the same matter - stopAnimation takes only one parameter (target) and is anyhow called when executing begingAnimation (https://github.com/BabylonJS/Babylon.js/blob/master/Babylon/babylon.scene.ts#L679) , so this is redundant. But I doubt this is the problem...

Link to comment
Share on other sites

Hi, RaananW. 

I finally found the problem,  but I don't know if is a bug, or I  is a problem in my code. 

 

 

Here are solution: :)

BABYLON.SceneLoader.ImportMesh("",url,"lion.babylon", scene, function (m, p, s) {m[0].active_animation = 1;m[0].skeleton = s[0]; m[0].anim_fin = false;var on_end = function(){ m[0].anim_fin = true;}var check = setInterval(function(){  if(m[0].anim_fin){     m[0].active_animation = parseInt((Math.random() * 10) + 1);     scene.beginAnimation(m[0].skeleton, setting[m[0].active_animation].from, setting[m[0].active_animation].to, false,1,on_end);     m[0].anim_fin = false;  }},200)scene.beginAnimation(m[0].skeleton, setting[m[0].active_animation].from, setting[m[0].active_animation].to, false,1,on_end); });

And now, I'll try to explain the problem.

 

It enters the "on_end" function various times, at the end of one animation, not just once. I started an animation, it finishes and then enters the function "on_end"  3,4 times, not only one time, for each animation, then again in the function several times and so on until all the animations  get blocked.

 

 

I make a playground, but there work fine, u can see that in console.

http://www.babylonjs-playground.com/#1HUCSD

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