Misaki spine-pixi 也可以用这个方法吗,我使用下面的代码,还是感觉切换之后,头发会大幅度抖动

spineInstance.skeleton.updateWorldTransform(spine.Physics.reset)
spineInstance?.state.setAnimation(index, item.poseName, true)
    Related Discussions
    ...

    hh_x Your question was originally posted as a reply to the question thread about physics issues in Unity, but I split the thread since the runtime you are using is spine-pixi.

    Note that updateWorldTransform(spine.Physics.reset) should be called after the next animation has been applied, because when this is called, the physics are reset for the current pose. In other words, if it is called before the next animation is set, it may not work because the physics will just be reset for the previous animation pose. I am not very familiar with how to specify the order of execution in spine-pixi, so if you are not sure about that, you might want to wait for an answer from @Davide .

    Hello 🙂

    Here is the function that is invoked by the ticker attached to the Spine object.
    As you can see, it performs the following operations:

    ...
    this.state.update(time);
    this.skeleton.update(time);
    
    const { skeleton } = this;
    
    this.state.apply(skeleton);
    
    this.beforeUpdateWorldTransforms(this);
    skeleton.updateWorldTransform(Physics.update);
    this.afterUpdateWorldTransforms(this);
    ...

    The skeleton.updateWorldTransform is always updated with Physics.update.

    You can approach this in two ways:

    1. Manually write your own update logic.
    2. Use the afterUpdateWorldTransforms hook to invoke updateWorldTransform with Physics.reset.

    The second approach is more straightforward, though slightly tricky. You need to set Physics.reset for a single frame and then revert it; otherwise, the physics system will stop working. Here's an example of how you could implement this:

    spineObject.state.setAnimation(0, "eyeblink", true); // Set a new animation
    const prevAfterUWT = spineObject.afterUpdateWorldTransforms; // Store the current version of afterUpdateWorldTransforms
    
    // Set a custom afterUpdateWorldTransforms hook to be invoked just once
    spineObject.afterUpdateWorldTransforms = () => {
    	// Invoke updateWorldTransform with Physics.reset
    	spineObject.skeleton.updateWorldTransform(spine.Physics.reset);
    
    	// Restore the previous afterUpdateWorldTransforms hook
    	spineObject.afterUpdateWorldTransforms = prevAfterUWT;
    };
      12 days later

      Davide 我用第二种方法成功实现了应用动画取消物理效果,🙏感谢您的回复

        hh_x

        You are very welcome! If you need further assistance, don't hesitate to reach out to us 🙂