Recognise a hips bone without Avatar Animator
This commit is contained in:
parent
fd9bc37467
commit
67126399e6
@ -620,6 +620,14 @@ namespace Passer.Humanoid {
|
||||
return animators[i];
|
||||
}
|
||||
}
|
||||
|
||||
SkinnedMeshRenderer[] meshRenderers = avatarRoot.GetComponentsInChildren<SkinnedMeshRenderer>();
|
||||
for (int i = 0; i < meshRenderers.Length; i++) {
|
||||
if (meshRenderers[i].rootBone != null) {
|
||||
Debug.Log("Found a skinned mesh with bones");
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -270,6 +270,12 @@ namespace Passer.Humanoid {
|
||||
boneId = Bone.Hips;
|
||||
}
|
||||
|
||||
public override void RetrieveBones(HumanoidControl humanoid) {
|
||||
base.RetrieveBones(humanoid);
|
||||
if (bone.transform == null)
|
||||
HumanoidTarget.GetDefaultBone(humanoid.transform, ref bone.transform, "Default_simple|Hips");
|
||||
}
|
||||
|
||||
public Vector3 GetForward() {
|
||||
HumanoidControl humanoid = hipsTarget.humanoid;
|
||||
if (humanoid.rightFootTarget.upperLeg.bone.transform == null || humanoid.leftFootTarget.upperLeg.bone.transform == null)
|
||||
|
@ -224,6 +224,20 @@ namespace Passer.Humanoid {
|
||||
if (boneTransform != null)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public static void GetDefaultBone(Transform root, ref Transform boneTransform, params string[] boneNames) {
|
||||
if (boneTransform != null)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < boneNames.Length; i++) {
|
||||
if (boneNames[i] == null)
|
||||
continue;
|
||||
|
||||
boneTransform = root.FindDeepChild(boneNames[i]);
|
||||
if (boneTransform != null)
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -401,7 +415,7 @@ namespace Passer.Humanoid {
|
||||
return obj.transform;
|
||||
}
|
||||
|
||||
public void RetrieveBones(HumanoidControl humanoid) {
|
||||
public virtual void RetrieveBones(HumanoidControl humanoid) {
|
||||
if (humanoid.targetsRig != null)
|
||||
GetDefaultTargetBone(humanoid.targetsRig, ref target.transform, boneId);
|
||||
if (humanoid.avatarRig != null)
|
||||
|
Loading…
x
Reference in New Issue
Block a user