在unity中,我试图用Spine组件来控制游戏角色,并启用unity的Transparancy Sort Axis来根据y轴动态调整角色和地图物品之间的遮挡关系。但是我发现,对于角色,unity使用中心点坐标来比较它和其他物体的y轴坐标,所以有时候遮挡关系有些不对劲。
如果使用sprite renderer,我可以调整图片的pivot位置,这样可以调整y轴的比较坐标。但是对于spine组件来说,我该怎样调整,以达到同样的效果呢?谢谢!
=====
In unity, I tried to use the Spine component to control the game characters, and enabled unity's Transparancy Sort Axis to dynamically adjust the occlusion relationship between characters and Tilemap items based on the Y-axis. But I found that for characters, unity uses the center point coordinates to compare it to the Y-axis coordinates of other objects, so sometimes the occlusion relationship is a little off.
If I use the sprite renderer, I can adjust the pivot position of the image so that I can adjust the Y-axis comparison coordinates. But for the spine component, how can I tweak it to achieve the same effect? Thank you!
Page 1 of 1
Raindow00S
2 months ago
- Raindow00S
- Posts: 10
Harald
您可以偏移
-----
You can offset the
skeleton.Y
值:skeletonAnimation.Skeleton.Y = offsetY;
或者,您可以修改根骨骼的位置。 但是,除非有人反对设置 skeleton.Y
,否则我们不推荐这样做。-----
You can offset the
skeleton.Y
value:skeletonAnimation.Skeleton.Y = offsetY;
Alternatively you could modify the position of the root bone. However, we would not recommend this unless something speaks against setting skeleton.Y
. 2 months ago
-
Harald - Posts: 4459
Raindow00S
感谢您的回答!我尝试了偏移Skeleton.Y,骨骼的位置确实整体偏移了,但似乎在遮挡关系上,unity还是在使用它的中心值进行比较。您提到了根骨骼,根骨骼的位置能发挥什么作用吗?它现在位于角色的脚下。Harald wrote:您可以偏移skeleton.Y
值:skeletonAnimation.Skeleton.Y = offsetY;或者,您可以修改根骨骼的位置。 但是,除非有人反对设置skeleton.Y
,否则我们不推荐这样做。
-----
You can offset theskeleton.Y
value:skeletonAnimation.Skeleton.Y = offsetY;Alternatively you could modify the position of the root bone. However, we would not recommend this unless something speaks against settingskeleton.Y
.
=====
Thank you for your reply! I've tried offset the Skleton.Y, and the Skeleton position is actually offset overall, but it seems unity is still using its central point for comparison when it comes to occlusion relationships.
You mentioned the root bone, what role does the position of the root bone play? It is now at the feet of the character.
捕获22.JPG
捕获23.JPG
---
我可能找到解决方式了!我的做法可能有几个毛病导致没达到想要的效果:
1.从图上看,我的角色的pivot本来就在中心,可能是因为在spine中,我把角色中心放在了原点位置。(原点应该在脚下。)
2.我没有在Sprite Renderer中将Sort Point调整为Pivot。
3.添加Sorting Group应该能解决问题。
参阅以下帖子:
http://en.esotericsoftware.com/forum/Animation-pivot-point-7713
http://en.esotericsoftware.com/forum/Pivot-point-redefined-in-the-wrong-place-13016
http://en.esotericsoftware.com/forum/Sprite-Sort-Point-for-Spine-10783
这是我的探索记录,但我还没有验证是否有效。如果起作用了,我再来记录一下。

=====
I may have found a solution! There may be several flaws in my approach which may not achieve the desired effect:
1. It can be seen that the pivot of my character is at the center, which may be because I place the character center at the origin in the spine. (The origin should be at the foot.)
2. I didn't adjust Sort Point to Pivot in the Sprite Renderer.
3. Adding a Sorting Group should solve the problem.
See the following post:
http://en.esotericsoftware.com/forum/Animation-pivot-point-7713
http://en.esotericsoftware.com/forum/Pivot-point-redefined-in-the-wrong-place-13016
http://en.esotericsoftware.com/forum/Sprite-Sort-Point-for-Spine-10783
This is my learn record, but I haven't verified it yet. If it works, I'll write it down again.

You do not have the required permissions to view the files attached to this post.
2 months ago
- Raindow00S
- Posts: 10
Harald
由于
-----
Since
SkeletonAnimation
使用 MeshRenderer
而不是 SpriteRenderer
,恐怕没有选项可以将排序点设置为枢轴。 但是,您可以创建一个简单的脚本,将 meshRenderer.sortingOrder
设置为您的 Transform Y 值。-----
Since
SkeletonAnimation
uses a MeshRenderer
and not a SpriteRenderer
, I'm afraid there is no option to set the sort-point to the pivot. You could however create a simple script that just sets meshRenderer.sortingOrder
to your Transform Y value. 2 months ago
-
Harald - Posts: 4459
Raindow00S
谢谢!我尝试加了Sorting Group组件,它起作用了,虽然不知道原理是啥。这暂时够满足我的需求了!Harald wrote:由于SkeletonAnimation
使用MeshRenderer
而不是SpriteRenderer
,恐怕没有选项可以将排序点设置为枢轴。 但是,您可以创建一个简单的脚本,将meshRenderer.sortingOrder
设置为您的 Transform Y 值。
-----
SinceSkeletonAnimation
uses aMeshRenderer
and not aSpriteRenderer
, I'm afraid there is no option to set the sort-point to the pivot. You could however create a simple script that just setsmeshRenderer.sortingOrder
to your Transform Y value.
=====
Thanks! I tried the Sorting Group component and it worked, although I don't know how. That's enough for my needs for now!
2 months ago
- Raindow00S
- Posts: 10
Harald
感谢您回复我们,很高兴对您有所帮助!
Thanks for getting back to us, glad it helped!
Thanks for getting back to us, glad it helped!
2 months ago
-
Harald - Posts: 4459
Mark topic unread
• Page 1 of 1
Return to 中国Spine用户
- All times are UTC