• RuntimesUnity
  • [Unity] About Z-Position of SkeletonUtilityBone

Hello.

I have a question about the Z Position function of SkeletonUtilityBone.
I place a Spine object in 3D space.
I would like to use SkeletonUtilityBone's override to move the z-position of some bones.
However, even if I move the z-position, it is not reflected.
When I checked the source code of SkeletonUtilityBone, it seems that Z-Position function was not implemented.
Is it currently not possible to move the Z-position?

Thank you.

Related Discussions
...

@kido0617 I'm sorry to say that Z Position is only respected when using Mode Follow. Please note that a Bone in a skeleton has no Z-position, it is only represented in 2D space internally. In the resulting mesh, any attachment's Z position is defined via the Inspector property Advanced - Z Spacing combined with the current draw order.

It would also not be well-defined what should happen if you could change the Z position of all attachments at a given bone, since draw order dictates which attachments are drawn on top of other attachments. Moving their Z-position would not change that since usually skeleton shaders don't write to the depth-buffer on purpose. As a result you would get an attachment which is moved far-back but which still renders on top of other attachments that are in front of it in terms of Z-position.

Mentioning for sake of completeness:
Regarding following Z position, there has been a bug which is fixed on 4.2-beta but will not be fixed on 4.1 to not break existing projects:
EsotericSoftware/spine-runtimes2255
So on spine-unity 4.1, the Z Position property has no effect.

@kido0617 What do are you trying to achieve, which leads you to wanting to modify the Z-position of a bone or attachment?

Thank you for your explanation. I understand.
What I want to do is randomly blow away enemy parts when the enemy explodes.
I wanted the bone to move in the Z direction when it explodes like in this video.

    kido0617 Harald will be unavailable until November 12th as he is on vacation. I'm sure he'll give you some advice when he gets back, so I hope you'll wait until then.

    10 jours plus tard

    @kido0617 Sorry for the late reply, thanks for sharing the video.

    Potentially the easiest way would be to split the skeleton mesh into multiple parts via a SkeletonRenderSeparator component, isolating each part that should be split off as a separate MeshRenderer GameObject. This would allow you to freely move parts around while still automatically sorting everything correctly.

    I had no idea to use SkeletonRenderSeparator.
    I solved the problem.
    Thank you!

    @kido0617 Glad to hear it helped.
    BTW: Your game looks (and also sounds) very cool!