Hi, quick question:
What is the correct approach to control the position of a Bone at runtime? Should I set bone.Data.X/Y directly or should I use bone.SetPosition()? Bone.SetPosition doesn't seem to work for me at runtime, but it does in the inspector, and vice versa outside of playmode. Is it dependent on whether the bone has been keyframed in the setup pose / current animation?
This is how I'm doing it currently during playmode:
Bone eyeGroup;
Vector2 eyesStartPos;
void Awake()
{
eyeGroup = mySkeleton.Skeleton.FindBone("eyeGroup");
eyesStartPos = new Vector2(eyes.Data.X, eyes.Data.Y);
}
void MoveEyes(Vector2 amount)
{
eyeGroup.Data.X = eyesStartPos.x + amount.x;
eyeGroup.Data.Y = eyesStartPos.y + amount.y;
}
Should I be doing this instead?
Bone eyeGroup;
Vector2 eyesStartPos;
void Awake()
{
eyeGroup = mySkeleton.Skeleton.FindBone("eyeGroup");
eyesStartPos = eyeGroup.GetLocalPosition();
}
void MoveEyes(Vector2 amount)
{
eyeGroup.SetPosition(new Vector2(eyesStartPos.x + amount.x, eyesStartPos.y + amount.y));
}
Does it matter? Are both the same?
Thanks!
28 Apr 2017, 04:09
Or... should I subscribe to SkeletonAnimation.UpdateLocal and update the position that way?