- Изменено
How to get Bone weight
Hi all,
I am trying to create a script in Unity 2019.2.2f1 where I am moving the vertex of the mesh collider in order to follow the shape of the mesh.
I already have a script that works perfectly with a skinned mesh renderer, but of course, the component that I can use right now is the Mesh filter.
To do so I need to use the weight of the bones in order to have next position, is there a way to get the bones weight from the skeleton?
Thanks
Just a side note, in case you don't know: you can use a BoundingBoxFollower to have a PolygonCollider adapt to a Bounding Box defined in the Spine editor every frame.
Regarding your question:
We absolutely do not recommend to reinvent the wheel and write your own code to re-transform every vertex of the mesh every frame. Since you mentioned "in order to have next position": Is the mesh state of the current frame not an option? We would suggest to get the mesh from the MeshFilter after SkeletonRenderer's LateUpdate()
call. You might want to configure your script execution order to run after SkeletonRenderer
and SkeletonAnimation
.
If you really need the next frame, we would rather suggest to either derive your own subclass from SkeletonAnimation
and generate your own additional "next frame" mesh accordingly (see code in SkeletonRenderer
) or have a second invisible copy of your SkeletonAnimation object that is set to one frame ahead.
Hello,
Sorry for the late reply,
As you said "Since you mentioned "in order to have next position": Is the mesh state of the current frame not an option?", I decide to use this option and thanks to your first solution everything is working like a charm(but not in LateUpdate but in Update).
So, thank you very much
Glad to hear that it worked, thanks for letting us know!