Skip to content

Commit

Permalink
Fix tranfsorming of transform when parent is a bone
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom-Ski committed Oct 16, 2024
1 parent 86c0629 commit 95634ef
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@ public static Vector2 worldToLocal(GameObject gameObject, Vector2 vector) {
if(gameObject == null) {
return vector;
}

if (gameObject.hasComponent(BoneComponent.class)) {
BoneComponent boneComponent = gameObject.getComponent(BoneComponent.class);
Bone bone = boneComponent.getBone();

vector.sub(bone.getWorldX(), bone.getWorldY());
vector.sub(gameObject.getTransformSettings().offsetX, gameObject.getTransformSettings().offsetY);

vector.rotateDeg(-bone.getWorldRotationX());
vector.scl(1f/ bone.getScaleX(), 1f/ bone.getScaleY());

return vector;
}

if(gameObject.parent == null) {

//Check if root has transform component
Expand Down

0 comments on commit 95634ef

Please sign in to comment.