- Modifié
Procedural bone deformation
Hello
I'm would like to know if it's possible to apply some offset and change the scale of the bones of a animated skeleton at runtime , here is what I do at the moment :
I use this callback in order to apply scale / offset to selected bones
m_Skeleton.UpdateLocal += Skeleton_UpdateLocal;
by using the following (m_Bones is an array of ):
position = m_Bones[boneIndex].m_Bone.GetLocalPosition();
m_Bones[boneIndex].m_Bone.SetLocalPosition( position + offset );
m_Bones[boneIndex].m_Bone.ScaleX = xvalue;
m_Bones[boneIndex].m_Bone.ScaleY = yvalue;
I thought the bone value will just be reset everytime UpdateLocal is called but that doesn't seem to be the case.
So just applying adding scale will just accumulate it.
Same for the position it looks like the offset will just accumulate by doing this.
Any advice on how I could achieve this ?
Thanks a lot.
It depends on whether the playing animation has keyed the respective property. If you have, then it behaves as being "reset" before UpdateLocal
, if it is not keyed anywhere, you will end up accumulating the addition.
You can take a look at the Goblins
example scene, there each goblin provides an extraRotation
property to add to the head rotation:
spine-runtimes/Goblins.cs at 3.8. Here the rotation is not accumulated.
So to fix this, it should work to set a key at ScaleX
and ScaleY
of your target bone once at the start of the animation in Spine.
I see that makes sense, work like a charm, thanks !
Thanks for getting back to us, glad it helped.