• Unity
  • Bones Moving the Wrong Way - Instructions for Animamator?

I am working with an animator to rig up some eye bones. Different bones more in different directions when I make the same call to

bone.SetLocalPosition(new Vector2(1f, 0f);

We have confirmed that I am moving the correct bones.

Some bones move up when I increase x, some bones move to the left when I increase x. Some bones work perfectly, to the right when I increase x and up when I increase y.

The animator has the axes pointing all over. Sometimes the parent axes have the red arrow (x-axis) pointing down, sometimes to the right, sometimes up.

What instructions can I give to the animator to make

bone.SetLocalPosition(new Vector2(1f, 0f);

work predictably? I am thinking that the red arrow should always point to the right for all all of the parent bones from the eye bone to the root.

I should mention that this is my first time controlling bones from code and I do not know the Spine tool.
Cheers

Related Discussions
...

You should tell your animator to orient all parent bones of eyes consistently, e.g. so that red is oriented right (he can use the Compensation feature to adjust only the parent and not the children). There is no reason why parent bones of eyes should point in all different directions, it should be cleanly set up and consistent across different characters.

Alternatively, you could use Bone.WorldToLocal(position) (needs to be called twice with vector.zero and direction if you want to transform a direction vector) or Bone.GetWorldToLocalMatrix() to transform a world-space direction vector to a local vector that you can add to the bone's local position.

Another way would be to use the SkeletonUtilityEyeConstraint example component (with a SkeletonUtilityBone component) as shown in the Spine Examples/Other Examples/SkeletonUtility Eyes example scene.

That's the answer I was looking for, thank you!

You're welcome.