Zino54220 Posted May 26, 2014 Share Posted May 26, 2014 Hi Gentlemen! The question is in the title... Can I change the execution speed of an animation with/in Babylon? Let me explain : I have a skeleton imported from Blender in Babylon. This skeleton has many animations.In my game projet, I have many characters based on the same skeleton. So, characters all have the same animations. Now my problem : I would like to make animations be differents in playing although they have the same skeleton. Why?Because I have many animations which are the same except the speed execution between the different characters. Otherwise, I will have to make an animation by characters and I prefer factorize as possible my code...(Especially if the animation is the same!) Thank you for your opinion on this issue. Zino Quote Link to comment Share on other sites More sharing options...
Kilombo Posted May 26, 2014 Share Posted May 26, 2014 Hi Zino. I see a way for you to do that. You can use objects (OOP), that way the skeleton and the speed become one object propertie that you can change. That way you can use the same animation (and mesh) in all the objects, but using diferent speeds in each of them.you can use somthing like. caracter1 = new caracter();caracter2 = new caracter();and then, caracter1.animspeed(2);caracter2.animspeed(5); Hope i've beem helpuff. Best regards. Quote Link to comment Share on other sites More sharing options...
Zino54220 Posted May 26, 2014 Author Share Posted May 26, 2014 Thanks Kilombo! I will see your way as soon as possible and I will inform you. Quote Link to comment Share on other sites More sharing options...
gwenael Posted May 27, 2014 Share Posted May 27, 2014 Hi Zino. I see a way for you to do that. You can use objects (OOP), that way the skeleton and the speed become one object propertie that you can change. That way you can use the same animation (and mesh) in all the objects, but using diferent speeds in each of them.you can use somthing like. caracter1 = new caracter();caracter2 = new caracter();and then, caracter1.animspeed(2);caracter2.animspeed(5); Hope i've beem helpuff. Best regards. Unfortunately, I'm not sure that answers to what Zino54220 really needs: Can I change the execution speed of an animation with/in Babylon? But of course, that could be wrapped into animspeed function. Quote Link to comment Share on other sites More sharing options...
Zino54220 Posted May 27, 2014 Author Share Posted May 27, 2014 Hi Gwenael ! An animspeed function ? ............. Is it an already existing method or I must create it?? There is a property in the skeleton which may alter the speed of an animation??? Thank you for your reply. Quote Link to comment Share on other sites More sharing options...
gwenael Posted May 27, 2014 Share Posted May 27, 2014 Maybe there is a similar function but that was not what I was saying. I was pointing out that's your real issue is to know how to change the execution of an animation and once you've figured it out you could use Kilombo's approach: use of a character class with a animspeed in it (that would be your job to write this class). Quote Link to comment Share on other sites More sharing options...
gwenael Posted May 27, 2014 Share Posted May 27, 2014 Here's something that could help youanimate(target, delay: number, from: number, to: number, loop: boolean, speedRatio: number)You'll find this function in Animation class https://github.com/BabylonJS/Babylon.js/blob/master/Babylon/Animations/babylon.animation.ts 'speedRatio' could be what you are looking for Quote Link to comment Share on other sites More sharing options...
Zino54220 Posted May 27, 2014 Author Share Posted May 27, 2014 Ok, this seems like a good idea. I already create a class for my character and I will add the animate method (because actually, I use scene.beginAnimation()) But i'm a beginner in Javascript and this is not the same logic that C++, C#, Java, ... (Specially the lifetime variables) For example, I will try to get my skeleton imported in a variable of type "var" or type "BABYLON.SKELETON" but it exist only in my rollback method defined in the importe methode "BABYLON.ImporteMesh." and after my import method, it no longer exists. (I will try to get it by id...) In short, I must improve myself in Javascript Thanks again for your replies Quote Link to comment Share on other sites More sharing options...
gwenael Posted May 27, 2014 Share Posted May 27, 2014 You may want to use Typescript. babylon.js is being ported to it. Quote Link to comment Share on other sites More sharing options...
Kilombo Posted May 27, 2014 Share Posted May 27, 2014 Hey mate, there's no problem with that. Javscript doen't need type definitions like Java or C++, so you can just write something like: var caracter1 = newMesh[0]; or else, work on something like i did, and do something like: var scout1 = new unit(); scout1.load3D("transport","transport.babylon");The unit is class. Load3D() is a method of the class that receives has args the name of the mesh and the path, and with that load the mesh. I hope i've been helpfull, pm me for more details if you need them. 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.