Jump to content

Change the animation speed from a skeleton with Babylon?


Zino54220
 Share

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Hi Gwenael  :) !

 

 

An animspeed function ?

 

.............  :huh:

 

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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