setCurrentTime() display different animation than expected

Hi.

I have an animation clip with 9 animation frame in range 0.00 and 0.09, 1 frame every 0.01 seconds and trying to set the animation to be random using the setCurrentTime() method. however, when I enter 0.09, it is displaying the animation at 0.06 seconds for some reason.

This is how my code looks like:

start(){
var random = cc.math.randomRange(0.00,0.09).toFixed(2);
var animation = this.node.getComponent(cc.Animation);
animation.setCurrentTime(random);
animation.stop(“Animation”):
}

The problem is, even if the value 0.09, it is displaying the animation at 0.06 seconds. If I get the Current animation time it is return 0.09 which is correct yet it is not displaying the animation I am expecting.

An other weird thing is that in order to be able to set the animation time the animation need to play and then I need to stop it. If the animation does not play, I can not change the animation. So that is why I am stoping the animation after setCurrentTime() in case anyone wondering.

Does anyone have any idea why is this happening?
Thank you.

I have created a small demo, reproducing the problem:
https://gofile.io/d/eQ3gpL

I am new to Cocos Creator so it could easily be something I`m missing or doing wrong but can not figure out what is it.
Appreciate any help.

Thank you.

It seems to be a limitation of the Animation system in cocos. I guess when I set the current time, it is not 100% accurate, it may be a little more or less with a few decimal values internally and so if I work with such a low time frames like 0.01 seconds, it is cause problems like this. If I set the frames higher in range 0-9 seconds instead of 0.00-0.09, it is solve the problem. :+1:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.