- Edited
Getting position of point attachment
Another newbie question. I have a point attachment in my hierarchy. I would like to, in code, get the position of that attachment. I imagine that there is a simple way to do this, but I can't seem to track it down. Can anyone help?
You can use PointAttachment#computeWorldPosition()
by passing in the bone to which the attachment is attached. This will give you coordinates relative to the skeleton's origin.
You can use a PointFollower
component for this purpose - create an additional GameObject and attach a PointFollower
for each PointAttachment which will then follow position and rotation as configured - you can set followRotation
, followSkeletonFlip
, followSkeletonZPosition
according to your needs.
Thanks to both of you! That point follower component is genius. Love it!
For some reason the point follower script thows this error over and over whenever I come back to Unity from Visual Studio (or sometimes if I select an object other than the one that holds the script).
NullReferenceException: Object reference not set to an instance of an object
Spine.Unity.PointFollower.UpdateReferences () (at Assets/Spine/Runtime/spine-unity/Components/PointFollower.cs:95)
Spine.Unity.PointFollower.LateUpdate () (at Assets/Spine/Runtime/spine-unity/Components/PointFollower.cs:111)
Running the project works fine and the point follower performs as expected. All of the relevant data is set in the script (skeletonAnimation, slot, and point) so I'm not sure why this is happening.
Thanks for the info, this is indeed a bug. I just committed a bugfix for it, will be included in the next unitypackage update - published later today.
Awesome! Glad to be of service.
So I can download later today and get the fix?
Nevermind. Just saw the commit and got it. Thanks again!
You can download the unitypackage here now:
Spine Unity Download
(Be sure to refresh the page in your browser)
PointAttachment#computeWorldPosition() I am having trouble understanding how to use this. I am typing in PointAttachment point.computeWorldPosition(Face); and nothing happens, tried a bunch of other things too, no luck so far. I simply do not know how to access these methods, they seem to be unavailable for me.
Without additional context it will be difficult to guess the surrounding code and your skeleton setup.
Since you have posted on another related forum thread as well: I assume this issue has been resolved through the BoneFollower
adaptations, or is this still relevant?