Zino54220

Change the animation speed from a skeleton with Babylon?

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

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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).

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.