• Runtimes
  • Using attachments with external assets

Is it possible to use attachment points with external image assets? Our use case is that we'd like to make a spinning prize wheel and each slot would have an attachment point where we can load in various external images to those points and have them spin with the wheel so it looks like they're one asset.

If it's not possible to load external assets directly would it be possible to somehow get the world position of each of the attachment points as it spins and then we can write some custom code in our game to rotate the images to match the rotating attachment positions?

Related Discussions
...

Yes, that is of course possible. Which runtime are you using?

I'm using the C++ runtime.

The spine-cpp runtime is a generic runtime. Are you use a game toolkit or your own framework for rendering?

Here is a section on creating attachments at runtime:
Runtime Skins - Spine Runtimes Guide: Creating attachments

It may help to look at how SkeletonJson or SkeletonBinary creates an attachment:
spine-runtimes/SkeletonJson.cpp at 3.8
You can do the same, probably providing your own AtlasRegion instead of having the AttachmentLoader do it. This is the part the AtlasAttachmentLoader does:
spine-runtimes/AtlasAttachmentLoader.cpp at 3.8

A simpler solution may be to replace the AtlasRegion for attachments that you setup in Spine. You could use Skeleton getAttachment, then set the renderer object to a different AtlasRegion and also set the RegionAttachment uvs, as shown in the AtlasAttachmentLoader above.

The above would be how to do it using the Spine Runtimes APIs, which has the benefits that your image is a real Spine attachment, so it can participate in draw order, be affected by weights, etc. If you want an even simpler solution, you can draw your skeleton, then get the world transform (eg the position and rotation) of a bone (or point attachment) and draw images at that location. That drawing would be completely on top of your skeleton, but may be sufficient for your needs.

We're using Lumberyard as our game engine so I integrated the C++ runtime into it. The images we want to create and load at runtime probably won't be made in Spine as they're just static 2D images. I think the simplest solution is to get the position and rotation of a bone/attachment point from Spine and then send it to our rendering engine to draw the separate 2D image using that same transform. Is there anything in the documentation that you can point me towards on doing that?

Oh, it would be interesting to see a Lumberyard runtime!

Sure, SkeletonData findBone to get the bone you need, then Bone worldX, worldY, and worldRotation to get the position and rotation to draw at. The origin for the bone's world position is 0,0 in Spine (which is the skeleton position at runtime, Skeleton x and y).

6 days later

Thanks, I'll give that a shot next week.