• Editor
  • List of commands / Techniques?

Hi,

I'm a Unity spine user and I'm wondering how to perform the following things, if possible, please forgive the rather large list:

  1. Change colors of the entire skeleton in one go, ie turn monster red when angry in code.

  2. Scaling the entire thing, ie stretch it in code, without using transform (so batching isn't broken in Unity) - includes flipping I suppose if a negative scale.

  3. What do the params do for these:

    skeletonAnimation.state.SetAnimation("jump", false);
    skeletonAnimation.state.AddAnimation("walk", true);
  1. How to know when an animation has finished playing (Unity) ?

  2. Most important for us We want to specify the z depth in 3d coordinates between the various quads that make up spine. This is so we can have a forearm of one spine object overlap another spine object while the the other arm passes behind the object. For example 2 spine animations having a hug. This should technically be possible afaik as I've done it before with a decent enough shader for depth. I wonder why I can't do it with spine though. It's not a niche thing either, imagine having 20 weapons and finding you can't slip it in between an arm or something... please advise as it's a deal breaker 🙁

  3. Does set Attachment do this in Unity? Or does it not count because the attachment has to use same atlas?

any tips will help us learn your API! Thank you.

Related Discussions
...

Btw regarding the lack of any kind of Z depth-

I managed to find some bone position commands but these only have X and Y. This shows you haven't really thought about the whole gamut of uses for spine. I can present a pretty superb reason why we need bones to have a Z component. For example:

  1. you have 10 characters
  2. you have 20 weapons, half of which tuck under the arm like assault rifles or bazookas

This makes it entirely unfeasible to add all the same weapon images to 10 different atlases, it just blows all atlases up twice as big for the sake of a lack of being able to define a depth to a bone or layer.

I was thinking - perhaps it's possible for me to retrofit this data. For example, when it loads, I could modify it so each bone Z is multiplied a tiny bit by it's layer, ie *1.001, and this should, if I add the right kind of data to spine C, give me the ability to slip a quad under his arm (which is all I really need to do).

This sort of thing (specifying a fixed Z) is also useful if your character wants to do anything else remotely interactive too such as stab an enemy or ride a horse.

Please advise me where I can look to solve this problem as its one of the actual reasons we purchased spine - to be able to attach things to other things - however I just can't work out how to slip objects between without it being part of the same skeleton (which isn't realistic for us, ie adding an entire invisible horse to each character?!)

Am I right in guessing that you already have a tiny bit of z depth between them, or are you using winding order? If you already add a little depth between them, is that exposed anywhere so I could manipulate how much apart each chunk is, perhaps layer 0 is at 0 and layer 1 is at 0.001, or such - just thinking out loud here 🙂

Thank you for your patience.

4. How to know when an animation has finished playing (Unity) ?

UP! I really need an answer for this question too. Thanks.

if (skeletonAnimation.state.IsComplete());

Returns true if no anim playing, or is completed.

hippocoder wrote
  1. Change colors of the entire skeleton in one go, ie turn monster red when angry in code.

Skeleton from spine-csharp has R, G, B, A fields.

  1. Scaling the entire thing, ie stretch it in code, without using transform (so batching isn't broken in Unity) - includes flipping I suppose if a negative scale.

You can set the scale on the root bone. Or, you can set the scale on the SkeletonJson when it is loaded.

Spine uses non-traditional scaling to avoid skew, so flipping must be done with Skeleton FlipX/Y.

  1. What do the params do for these:

    skeletonAnimation.state.SetAnimation("jump", false);
    skeletonAnimation.state.AddAnimation("walk", true);

setAnimation sets the current animation, clearing any queued animations. addAnimation queues an animation to play after all the currently queued animations.

  1. How to know when an animation has finished playing (Unity) ?

AnimationState isComplete, or when the animation time > animation.duration.

  1. Most important for us We want to specify the z depth in 3d coordinates between the various quads that make up spine. This is so we can have a forearm of one spine object overlap another spine object while the the other arm passes behind the object. For example 2 spine animations having a hug. This should technically be possible afaik as I've done it before with a decent enough shader for depth. I wonder why I can't do it with spine though. It's not a niche thing either, imagine having 20 weapons and finding you can't slip it in between an arm or something... please advise as it's a deal breaker 🙁

You can write your own renderer as needed. It isn't much code, see SkeletonComponent. However, for attaching things like guns to a skeleton, it may be easiest to use region attachments. Define all your guns in Spine (this allows you to specify the attachment offset SRT relative to the bone) then hide/show region attachments at runtime as needed. You can also create region attachments dynamically at runtime, though you may find it difficult to specify the attachment offset SRT programmatically unless you are careful how you create your images.

You can even create your own attachment types instead of using RegionAttachment, then you can draw anything you want. Your skeleton renderer needs to know how to draw of course.

  1. Does set Attachment do this in Unity? Or does it not count because the attachment has to use same atlas?

Currently the Unity atlas only supports a single backing image. I'm not sure how to support multiple. This would be a great contribution. 8) Note when you use multiple backing pages you may end up with many texture binds.

Woah amazing answers, thank you! I'll digest these. Coffee time!