Jump to content

How to dynamically change the animation speed without it skipping forward/back in time [Solved]


xiphiaz
 Share

Recommended Posts

Hello,

 

I'm having a bit of trouble working out how I can dynamically change the animation speed, while still maintaining the current frame the animation is up to when I make the change.

 

See demo here http://www.babylonjs-playground.com/#IBU2W7#2

 

When the speed changes I would hope that the current frame was not affected, so I can ramp down to a period of slow motion then resume back to normal speed

 

I suspect I might be mutating the wrong variable to change the speed, but I can't work out what might fix it

Link to comment
Share on other sites

13 minutes ago, Deltakosh said:

Hey @Deltakosh I was looking for something like this as well... My question is...since the property is called: scene.animationTimeScale, does that mean it increase the speed of ALL animations currently playing, not just the one I am interested in speed up.... Basically I need to be able to adjust the speed of the animation to match my movement speed so I don't get AS MUCH foot sliding... OR is there some already documented way of handing match the speed od movement to the speed of the animation ???

 

Link to comment
Share on other sites

Hey @adam how it going :)

 

Yeah I saw that tooo.. but looks like its at the scene level... Do you know what this it meant to do:

            var delay = this._animationTime;
            for (var index = 0; index < this._activeAnimatables.length; index++) {
                this._activeAnimatables[index]._animate(delay);
            }

 

Does that look like some kinda of '_animate()' function that take a delay... What that all about ???

Link to comment
Share on other sites

7 hours ago, xiphiaz said:

@Deltakosh great that works well (also works to make all animations reverse), however is it possible to control a single animation? I think this actually suits my needs, but it would be good to know if independent control is possible

Yo @xiphiaz ... What works Well???

Are you looking at an example the changes the animation speed ???

Is it the scene level or an individual animation ???

I could NOT tell from the answers above if we DO or DO NOT support scaling animation on the actual animatables (not the whole scene level).. I mean the example above ALSO directly uses:

this._activeAnimatables[index]._animate(delay);

First that looks PRIVATE... should we be messing with that directly???

And is 'DELAY' the actual Speed Ratio or What???

Can you show me please :)

 

Link to comment
Share on other sites

1 minute ago, Deltakosh said:

@xiphiaz : I'm just unsure why speedRatio is not enough in your case :)

Yo @Deltakosh Can you use speedRatio to update the speed of the currently LOOPING animation ???

I am really just looking for a way to match my animation speed up with my movement speed (BTW... Root Motion Solves All This... If you ever got a chance to look at the video I made for you about root motion... maybe you can help me get that feature working :))

Link to comment
Share on other sites

10 minutes ago, xiphiaz said:

@MackeyK24 the example that @Deltakosh gave which uses `scene.animationTimeScale` works for my purposes. I would however prefer to be able to do animation level scaling as it affects other things like camera animations which I don't really want.

 I thinks thats EXACTLY what I need as well ... Let me know if you find out or get this working.

I am still trying to get 'Root Motion' going which solves all my character animation movement problems as the animation root position magnitude drives the actual character at the proper animation speed... Don't have to modify animation on the fly because the stick value move the guy slightly faster BEFORE it reaches the threshold to play the next animation... YOU GET MAJOR FOOT SLIDE.

Link to comment
Share on other sites

14 minutes ago, Deltakosh said:

Ok the speedRatio change was kind of a bug, now it works better:

https://www.babylonjs-playground.com/#GT5VF1

 

The fix was deployed to github as well.

Sweet... So we can just use animatable.speedRatio DURING an already playing animation... Sweet... And can use scene.animationTimeScale for OVERALL animation speed control for the entire the scene ... Thanks @Deltakosh ... I will wait for next preview release distilled and update the toolkit from then :)

 

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