• Runtimes
  • Jittering when applying physicsTranslate - PixiSpine

I'm using Spine with PixiJS v8.

I'm creating a game with dynamic wind that players control the strength of. The player's avatar has physics constraints applied to their hair so it should respond to physics events.

To simulate the blowing of the wind I am calling physicsTranslate every frame on the skeleton and I pass in an x and y value according to the direction and strength of the wind. The hair responds to the call, but also constantly jitters as if vibrating.

Am I using physicsTranslate incorrectly? Should it be applied every frame? Does it need to be called at a certain time (before or after something in the Spine animation cycle)?

Any help would be useful.
Thanks!
Todd

Related Discussions
...

It seems like the jittering issue you're experiencing with physicsTranslate might be related to how and when you're applying it within the animation cycle. In general, physicsTranslate should be used to apply a transformation to the skeleton's world coordinates, and it should be called once per frame, ideally after posing the skeleton but before the final updateWorldTransform. This ensures that the physics constraints are applied correctly without causing jitter. Make sure that updateWorldTransform is only called once per frame after all transformations and physics updates have been applied. Additionally, ensure that your physics constraints are set to an appropriate FPS that matches or is a multiple of your rendering frame rate to avoid any discrepancies that could cause jitter.

Thanks, I'll try that out.

  • Davide ответили на это сообщение.

    todd

    This is the standard sequence of calls that occur during a frame update in spine-pixi-v8. Below is the same function, but with the invocations that are not relevant at the moment removed:

    private _updateAndApplyState(time: number) {
    	this.state.update(time);
    	this.skeleton.update(time);
    	this.state.apply(this.skeleton);
    	this.beforeUpdateWorldTransforms(this);
    	this.skeleton.updateWorldTransform(Physics.update);
    	this.afterUpdateWorldTransforms(this);
    }

    As you can see, there are also beforeUpdateWorldTransforms and afterUpdateWorldTransforms, which allow you to inject custom logic before updateWorldTransform is invoked.

    If you need further assistance, it would be helpful if you could share a clip and the code you are currently using, or, more generally, a minimal reproduction project.

    Thank you!

    • Davide ответили на это сообщение.

      todd

      I just want to add a piece of information.

      If you're still noticing some jittering, it might be due to the nature of physics constraints updating at a fixed rate. Nate wrote an exhaustive post about this in another thread.

      In that thread, the OP forked the runtime and modified the update rate. You can find their changes here.

      If you're experiencing this issue, you can patch the runtime as they did. We're planning to change this behavior in version 4.3.

      Thank you again! I saw that post yesterday as I was exploring the problem. I wouldn't be surprised if that's what is going on.