本文整理汇总了C#中Skeleton.FindBone方法的典型用法代码示例。如果您正苦于以下问题:C# Skeleton.FindBone方法的具体用法?C# Skeleton.FindBone怎么用?C# Skeleton.FindBone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Skeleton
的用法示例。
在下文中一共展示了Skeleton.FindBone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Apply
public void Apply () {
isActive = true;
skeleton = skeletonAnim.Skeleton;
mix = 1;
var ragdollRootBone = skeleton.FindBone(startingBoneName);
startingBone = ragdollRootBone;
RecursivelyCreateBoneProxies(ragdollRootBone);
rootRigidbody = boneTable[ragdollRootBone].GetComponent<Rigidbody>();
rootRigidbody.isKinematic = pinStartBone;
rootRigidbody.mass = rootMass;
List<Collider> boneColliders = new List<Collider>();
foreach (var pair in boneTable) {
var b = pair.Key;
var t = pair.Value;
Bone parentBone = null;
Transform parentTransform = transform;
boneColliders.Add(t.GetComponent<Collider>());
if (b != startingBone) {
parentBone = b.Parent;
parentTransform = boneTable[parentBone];
} else {
ragdollRoot = new GameObject("RagdollRoot").transform;
ragdollRoot.parent = transform;
if (b == skeleton.RootBone) {
ragdollRoot.localPosition = new Vector3(b.WorldX, b.WorldY, 0);
ragdollRoot.localRotation = Quaternion.Euler(0, 0, GetCompensatedRotationIK(b));
parentTransform = ragdollRoot;
} else {
ragdollRoot.localPosition = new Vector3(b.Parent.WorldX, b.Parent.WorldY, 0);
ragdollRoot.localRotation = Quaternion.Euler(0, 0, GetCompensatedRotationIK(b.Parent));
parentTransform = ragdollRoot;
}
rootOffset = t.position - transform.position;
}
var rbParent = parentTransform.GetComponent<Rigidbody>();
if (rbParent != null) {
var joint = t.gameObject.AddComponent<HingeJoint>();
joint.connectedBody = rbParent;
Vector3 localPos = parentTransform.InverseTransformPoint(t.position);
localPos.x *= 1;
joint.connectedAnchor = localPos;
joint.axis = Vector3.forward;
joint.GetComponent<Rigidbody>().mass = joint.connectedBody.mass * massFalloffFactor;
JointLimits limits = new JointLimits();
limits.min = -rotationLimit;
limits.max = rotationLimit;
joint.limits = limits;
joint.useLimits = true;
joint.enableCollision = enableJointCollision;
}
}
for (int x = 0; x < boneColliders.Count; x++) {
for (int y = 0; y < boneColliders.Count; y++) {
if (x == y) continue;
Physics.IgnoreCollision(boneColliders[x], boneColliders[y]);
}
}
var utilityBones = GetComponentsInChildren<SkeletonUtilityBone>();
if (utilityBones.Length > 0) {
List<string> destroyedUtilityBoneNames = new List<string>();
foreach (var ub in utilityBones) {
if (ub.mode == SkeletonUtilityBone.Mode.Override) {
destroyedUtilityBoneNames.Add(ub.gameObject.name);
Destroy(ub.gameObject);
}
}
if (destroyedUtilityBoneNames.Count > 0) {
string msg = "Destroyed Utility Bones: ";
for (int i = 0; i < destroyedUtilityBoneNames.Count; i++) {
msg += destroyedUtilityBoneNames[i];
if (i != destroyedUtilityBoneNames.Count - 1) {
msg += ",";
}
}
Debug.LogWarning(msg);
}
}
if (disableIK) {
foreach (IkConstraint ik in skeleton.IkConstraints) {
ik.Mix = 0;
}
}
skeletonAnim.UpdateWorld += UpdateWorld;
}