[tiny feature request] Get Length for Animation Sequence
Thank you very much for your idea on how to improve UE4. I have submitted your feature request to our developers. If you need to reference this request in the future, please refer to: UE-11947.
answered Mar 16 '15 at 06:52 PM
Considering the age of this topic, I am not sure whether you are still interested in a solution. Mind, I am not the most skilled programmer out there, so there are possibly better solutions. If you are willing to make a blueprint function library using C++, please do the following;
If you don't have your own function library yet, make a new C++ class in the engine. I think deriving from object is enough.
Then, in your .h file, add the following function (make sure a "public:" precedes it, otherwise the compiler will complain);
In your .cpp, add the following:
With this, you should be able to call on the length of whatever animation sequence you feed into the function. It also takes into account RateScale (since SequenceLength is the original imported length).
If there are any issues, let me know. Not all that familiar with helping people out with c++ and everything, so there may be mistakes in my explanation.
It appears that in 4.9.1 (and perhaps earlier versions, but not sure), there's a GetPlayLength node that can be used in the Animation Blueprint's EventGraph. The Target is an Anim Sequence Base, and the Return Value is the duration of the animation.
The tooltip for the GetPlayLength node says it returns the length of a Montage, but I use it on Anim Sequences directly just fine - no Montages needed.
Unfortunately, it doesn't appear to take the Rate Scale into account, which is too bad.
answered Sep 18 '15 at 04:28 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here