Jump to content

How to use animations on multiple meshes?


kaitek666
 Share

Recommended Posts

Hey! It's me again ;)

Since I started using BJS as my game engine, I've came across some problems I couldn't understand, but animations are the hardest for me.

Using this.tutorial I created an animation on my loaded model with several meshes. When I want to run my animation (here's a default one, from tutorial) only one (first) mesh is being animated.

 

Am I doing something wrong?

	RockRaider.prototype.walk = function() {
		var animationBox = new BABYLON.Animation("myAnimation", "scaling.x", 30, BABYLON.Animation.ANIMATIONTYPE_FLOAT, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);
		var keys = []; 

		keys.push({
			frame: 0,
			value: 1
		});
		keys.push({
			frame: 20,
			value: 0.2
		});
		keys.push({
			frame: 100,
			value: 1
		});

		animationBox.setKeys(keys);
		this.raider.forEach(function (mesh) {
            mesh.animations.push(animationBox);
        });

		this.raider.forEach(function (mesh) {
			scene.beginAnimation(mesh, 0, 100, true);
		});
		
	}

Please note: Putting them in separate forEach wasn't necessary. Firing them at once does not solve the problem.

 

I tried this solution as well, but it didn't do the trick:

		animationBox.setKeys(keys);
		this.raider.forEach(function (mesh) {
            mesh.animations.push(animationBox);
		//	scene.beginAnimation(mesh, 0, 100, true);
        });

		for(i=0; i<this.raider.length; i++){
			scene.beginAnimation(this.raider[i],0,100,true);
		}

 

Cheers!
Kajtek

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