Hello, I am new at Spine. I need to change one of my skeleton's bone to achieve aiming. I reviewed SpineBoy example scene and it seemed easy. But here is a problem. This code only works on SpineAnimation object which is on world. But my object is SkeletonGraphic and it is on Camera Canvas. How can I achieve same functionality with this code?
`public class SpineboyTargetController : MonoBehaviour {
public SkeletonAnimation skeletonAnimation;
[SpineBone(dataField: "skeletonAnimation")]
public string boneName;
public Camera cam;
Bone bone;
void OnValidate () {
if (skeletonAnimation == null) skeletonAnimation = GetComponent<SkeletonAnimation>();
}
void Start () {
bone = skeletonAnimation.Skeleton.FindBone(boneName);
}
void Update () {
Vector3 mousePosition = Input.mousePosition;
Vector3 worldMousePosition = cam.ScreenToWorldPoint(mousePosition);
Vector3 skeletonSpacePoint = skeletonAnimation.transform.InverseTransformPoint(worldMousePosition);
skeletonSpacePoint.x *= skeletonAnimation.Skeleton.ScaleX;
skeletonSpacePoint.y *= skeletonAnimation.Skeleton.ScaleY;
bone.SetLocalPosition(skeletonSpacePoint);
}
}`
I tried some position convertings but I cannot event move target bone. I want this functionality also works on Canvas SkeletenGraphic object.