How to play an anim/montage from a specific frame/ratio?

Hi,

This is a fairly specific technical issue we’ve hit, while trying to accomplish something that feels it should be quite simple. What we are trying to do is to play a simple one-off animation, but only to a certain extent. Imagine this case:

  • You have an animation pose of a character with his hand put together (like for a christian prayer) with the hands under his chin.
  • You have a second pose with the hands still together in the same fashion, but the arms are fully outstretched in front of the character.

What we need is to be able to somehow make the character stretch the arms in front ANY DISTANCE between the first pose (alpha: 0) and the second pose (alpha: 1) WITHOUT the hands separating.

  • The first thing we tried was naturally a simple blend. The massive problem with that was that: while the hands at alphas 0 and 1 were in perfect positions, on alphas 0.1 - 0.9 the hands were separating, because the rotation of the bones (elbows) gets interpolated linearly and we have no control over that.

  • This current approach we are trying is to use a montage that contains an animation of the full blend between the ‘outstretched’ pose to ‘under the chin’ pose, with hands in correct positions, and full control over each bone’s rotation. However to complete this technique I need to be to tell the montage to play from a certain point of the animation, e.g.:

  • if I need to blend from full stretch, I say: 100% of animation, play from frame 0.

  • if I need three quaters of the anim, I say: 75% of animation, play from frame 7 (0.25 of 30 frames anim)

  • if i need a tiny fraction of the anim, I could say: 1% of the anim, play from frame 29 (0.99 out of 30 frames anim)

Is there a way to play a montage from a specific point along its timeline to this level of control?

And please before you say to use sections, we would have to make each frame of each montage a new section and then write some kind of manager to determine which section of which percentage of the anim the section is, so with the current 12 montages of 60 frames each, we would have to set up 720 sections to start with. This is why we need a more modular approach.

If you have any alternative techniques you could recommend, that you know would work for our case here, that would be great too.

Kind regards,

Marcin

Hi Marcin,

So since you have it set up as a Montage you could call GetActiveInstanceForMontage and then call SetPosition on the FAnimMontageInstance that it returns. It’s a little clunky but it should work ok.

An alternative solution would be to drop the montage and use an Anim Evaluator node. These are made by adding the animation sequence to the graph as a standard sequence node, right clicking on it and selecting “Convert to single frame animation” This then gives you an evaluator node with an “Explicit Time” pin which allows you to control exactly what time the animation will be evaluated at each frame.

Hopefully that is helpful to you. Let us know if you have any further questions/issues!

Martin

Hi Martin,

Thank you for your ideas.

  • Unfortunately I had no luck finding GetActiveInstanceForMontage or SetPosition functions at all. Are you sure they aren’t C++ exclusive?

  • The Anim Evaluator node on the other hand allows to me get an exact frame I need, which is great, but at the same time forces me to run my own time calculations (timelines/on tick timers) to have the animation continue to play from that point onward. And the biggest problem with that, I have no way of knowing how long my animation is, because there is no GetAnimationLength node either. The only animation that ever returns length is a montage, which as you know cannot be used with this node, so for my needs it’s not very useful.

Kind regards,

Marcin

Unfortunately I had no luck finding
GetActiveInstanceForMontage or
SetPosition functions at all. Are you
sure they aren’t C++ exclusive?

Yes they are C++ exclusive sorry, nothing in your question said you were looking for non c++ solutions only.

As it stands there is no way to do this from blueprints. The easiest way to do this would be to expose the Montage_SetPosition to blueprints, obviously that would require an engine change at your end. You can do that by adding a UFUNCTION decleration like the other exposed montage functions:

UFUNCTION(BlueprintCallable, Category="Animation")

We can make the same change here but you would have to wait for it to get released (either in 4.13 or by manually merging a CL from our P4.

Cheers,

Martin

Hi Martin,

Thank you for the reply. I think making that change on your end would be great for other people, who might needs this functionality in the future.

I was pressed for time so I had to come up with my own solution, and fortunately for my case specifically, a blueprint timeline with scaled play rate and alpha curve worked much better than even the Anim Evaluator node ( I didn’t have to rely on specific position at specific time).

Kind regards,

Marcin