• Unity
  • Fire point position depending skins

Related Discussions
...

Hi,
I search solution to found firepoint position for my bullet depending skins.
I create 3 skins type long arm, normal, small. Each skin have different Fire Point location.
In Spine Editor, I define skin place holder with Point element, so i have 1 Point for each Skin.

But now i want to access this element with skeleton, but i not found any method return Point.
skeletonAnimation.skeleton.Find?

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);
}

Hi Pharan,

Thank you for all, i will try now. Sorry for my latence..