

Since Mathf.Atan or Mathf.Atan2 spits out an angle in radians, you need to convert that to degrees then just stick that number in as a rotational offset. To convert the ratio of those two lengths into an angle, you'll want the arctangent function. That has its own set of fields for local rotation, x, y, etc.įor the math, the straightforward option is using the trigonometric ratio between the differences in x and y of the frame of reference and the target. If you've already found the bone in question, it should be in that bone's.

If I'm not mistaken, that's under the BoneData class. On Spine's side, you'll want to access the setup pose and modify that, because as their video describes, all animations are relative to the setup pose. Just to have the bone rotated in relation to the target, I assume what you want is to mimick Unity's Transform.LookAt but in 2D That'd require something extra in your calculations. More precisely (if your sprites are rather large), tilting the upper body in the direction of the target wouldn't guarantee that the gun is pointed at the target too.
