In this specific case:
// Ideally, cache this stuff for your skeleton.
string slotName = "weapon_left_attack";
string placeholderName = "weapon_left_attack";
Skeleton skeleton = skeletonAnimation.Skeleton;
int slotIndex = skeleton.FindSlotIndex(slotName);
Slot slot = skeleton.Slots.Items[slotIndex];
// Then just use Skeleton.GetAttachment, which queries the active skin.
var pointAttachment = skeleton.GetAttachment(slotIndex , placeholderName) as PointAttachment; // will be null if not a PointAttachment.
if (pointAttachment != null) {
Vector3 worldPoint = pointAttachment.GetWorldPosition(slot, this.transform);
}
03 Jul 2017 8:28 pm
oops my bad. The above is also correct. But if the PointAttachment was active, it can be simpler:
// Ideally, cache this stuff for your skeleton so the script doesn't have to keep searching for it.
string slotName = "weapon_left_attack";
Slot slot = skeletonAnimation.Skeleton.FindSlot(slotName);
// Then get the active attachment as a PointAttachment
PointAttachment pointAttachment = slot.Attachment as PointAttachment;
if (pointAttachment != null) {
Vector3 worldPoint = pointAttachment.GetWorldPosition(slot, this.transform);
}