Play and resume animation inside script

I have created a Prefab containing a baked skeletal animation and a typescript. After some effort, I have observed something:

  • The animation can only play if I check the Play on load in the editor. No matter how I try to use play() inside the script, the animation will not run.
  • The node will always reset the position to its initial one if I choose the wrap mode as Loop.
    I want to control the position of the node and run the animation continuously without resetting its position. How can I achieve that?


  • The play() function can be used in the start function but not onLoad().
    Now I can play the animation in the script, the question is how can I get the current position from SkeletalAnimation to set the position for the parent node?

This code is from Creator v2.4.10, pls try if it works

const spineComp = charNode.getComponent('sp.Skeleton');
const isLoop = true;
spineComp.setAnimation(0, 'animationName', isLoop);

Thank you for your reply. But I am working with 3D animation in creator v3.8.