I have a Spine object where I am trying to change the position of a bone, but occasionally worldToLocal returns a different position than expected.

I have tried running updateWorldTransform before or after calling worldToLocal and changing the bone position, but it still occasionally returns an incorrect coordinate. This causes the bone to be positioned in a different coordinate from expected.
let position;
if (bone.parent) {
position = bone.parent.worldToLocal({ x: posX, y: posY });
else {
position = bone.worldToLocal({ x: posX, y: posY });
bone.x = position.x / bone.skeleton.scaleX;
bone.y = position.y / bone.skeleton.scaleY;
I am using the Pixi-Spine runtime.

Any idea what could be causing this?

Thank you!
  • Mesajlar: 1


Generally you want to call Skeleton updateWorldTransform which will update the world transform of the root bone, then update the bone transforms of all bones while also applying constraints. If you call only Bone updateWorldTransform it updates only that bone. If a parent bone's local transform has been changed, the parent bone needs to be updated, then all the child bones updated, recursively.

It could be that you are changing a bone's local transform but since you don't call Skeleton updateWorldTransform, it is not propagated to all the child bones. That change could even be from the previous frame. Since the previous frame is probably close to the next frame, maybe you just don't notice the error most of the time.

Also after you adjust the local transform, if you only call Bone updateWorldTransform, any child bones won't be updated and so their world transforms won't be affected by the adjustment.

Otherwise it's hard to say. Technically Bone worldToLocal cannot be wrong, so the problem must be elsewhere.
Kullanıcı avatarı

  • Mesajlar: 12144

Dön Runtimes