/// <summary> /// Anchors the mount point to the specified bone, essencially making /// this mount point a child of the bone. /// </summary> /// <param name="rBoneName">Bone name to anchor to or empty string to anchor to the root</param> public void AnchorTo(HumanBodyBones rHumanBodyBoneID) { if (rHumanBodyBoneID < 0) { return; } if (rHumanBodyBoneID > HumanBodyBones.LastBone) { return; } _BoneName = ""; Transform lParentTransform = _Owner.transform; if (_Anchor == null) { _Anchor = new GameObject(); } Animator lAnimator = _Owner.GetComponent <Animator>(); if (lAnimator != null) { lParentTransform = lAnimator.GetBoneTransform(rHumanBodyBoneID); if (lParentTransform != null) { _BoneName = MountPoints.GetHumanBodyBoneName(rHumanBodyBoneID); } } // Parent the mount point to this new transform. We don't // change it's position or rotation since we may need an offset. _Anchor.transform.parent = lParentTransform; }