swat0284 Posted January 24, 2017 Share Posted January 24, 2017 Hello i try to run 5 animations on 5 diffrent models but i have an error: Uncaught TypeError: Cannot read property 'frame' of undefined at i._interpolate (babylon.js:18) at i.animate (babylon.js:19) at e._animate (babylon.js:19) at i._animate (babylon.js:12) at i.render (babylon.js:12) at main.js:33 at n._renderLoop (babylon.js:4) My code is very silmpy function CreateAnimation(index) { var moveAnimation = new BABYLON.Animation("moveAnimation", "position", 30, BABYLON.Animation.ANIMATIONTYPE_VECTOR3, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE); //tworzenie animacji przemieszczania sie var moveKeys = []; var moveLenght = 0; console.log(checkpointsPositions[index].length +"checkpoints lenght"); for(var i = 0 ; i < checkpointsPositions[index].length ; i++) { //.toFixed(0) moveKeys.push({ frame: (jsonObjectResults.points[licznik].time)*30, value: (checkpointsPositions[index][i].position) }); console.log(checkpointsPositions[index][i].position + " +++ " + (jsonObjectResults.points[licznik].time).toFixed(0)*30); console.log("Licznik " + licznik); moveLenght++; licznik++; } licznik++; moveAnimation.setKeys(moveKeys); players[index].animations.push(moveAnimation); scene.beginAnimation(players[index], 0, jsonObjectResults.points[licznik-2].time*30, true); } I start the code by createAnimation(index of mesh) and when i run it once it works but when i run it more than one it doesnt work Quote Link to comment Share on other sites More sharing options...
RaananW Posted January 24, 2017 Share Posted January 24, 2017 Hi, I am not sure I get what you are trying to do. In each run of the for loop, you add further keys to the animation, and then you push the same object to the player in a specific index. You also don't reset the array, you simply add further objects. when you "setKeys" again, you "remove" the old keys, and then set the new ones. And, as far as I know (and this is probably the answer to the entire question) - animations cannot be shares between objects. Animation keys can be shared between animation objects, if you want to reuse. But you need an animation object per mesh. Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted January 24, 2017 Share Posted January 24, 2017 BABYLON.Animation instances maintain state. Running them on multiple meshes, as you have seen, does not work. The keys are what takes up all the space though. The array, you call moveKeys, is highly likely to work in multiple meshes Quote Link to comment Share on other sites More sharing options...
swat0284 Posted January 24, 2017 Author Share Posted January 24, 2017 So how can i generate ultiple animation for multiple objects Quote Link to comment Share on other sites More sharing options...
JohnK Posted January 24, 2017 Share Posted January 24, 2017 Don't know if these will help or not but have a look http://babylonjsguide.github.io/basics/Starter http://babylonjsguide.github.io/basics/Combine http://babylonjsguide.github.io/gamelets/Sequence jerome and GameMonetize 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.