I am currently working on changing the speed (playRate) of a walking animation programmatically based on the speed of my character and I am facing some problems.
I first started noticing that only changing the playRate itself messes up with the animation frame that is currently being shown. For example, if I am on frame 20 and I duplicate the playRate of my animation, my character will show the posture it had by frame 10, since it’s moving twice as fast. This results in visual glitches on my simulation.
After some trials I came to the conclusion that I needed to change the animationPlayStart variable too to adjust for this. I came up with this formula:
using this I can adjust the animationPlayStart and the playRate. For example, if I am on frame 20 and I duplicate the playRate of my animation and then adjust the animationPlayStart to be -20 then my character will show the same posture on frame 20, since it traveled twice the frames twice as fast.
I created a node in Omnigraph that takes my current frame and the speed the character is moving as inputs and calculates the playRate and the animationPlayStart accordingly and these are given to the animation on my sequencer. However I’m still seeing some glitching behavior.
My theory is that the calculation takes some time and the frame that I passed to my node is not the current one anymore, therefore my calculation comes up with a wrong animationPlayStart.
Is there a way to achieve what I am trying here? Is there a better approach?
So I updated the code again but I still get a similar glitching behavior.
I adjusted the formula to the following to take into account previous playRates and playStarts :
I created a very simple scene to recreate the issue with the default Worker human model of Omniverse and using it’s default animation, which is about 200 frames long. As you can see the first change in the animation speed (2nd second of the video) does work. But the second and third one (4th and 6th second of the video) do glitch:
Any input in the matter will be highly appreciated.