概要
スクリプトでPuppetMasterのRagdollを作成します。
※コレをスクリプトでやります。
実装
using UnityEngine;
using RootMotion.Dynamics;
public class Set : MonoBehaviour
{
[SerializeField] GameObject Obj;
void Start()
{
var anim = Obj.GetComponent<Animator>();
var r = new BipedRagdollReferences();
r.root = Obj.transform;
r.hips = anim.GetBoneTransform(HumanBodyBones.Hips);
r.spine = anim.GetBoneTransform(HumanBodyBones.Spine);
r.chest = anim.GetBoneTransform(HumanBodyBones.Chest);
r.head = anim.GetBoneTransform(HumanBodyBones.Head);
r.leftUpperLeg = anim.GetBoneTransform(HumanBodyBones.LeftUpperLeg);
r.leftLowerLeg = anim.GetBoneTransform(HumanBodyBones.LeftLowerLeg);
r.leftFoot = anim.GetBoneTransform(HumanBodyBones.LeftFoot);
r.rightUpperLeg = anim.GetBoneTransform(HumanBodyBones.RightUpperLeg);
r.rightLowerLeg = anim.GetBoneTransform(HumanBodyBones.RightLowerLeg);
r.rightFoot = anim.GetBoneTransform(HumanBodyBones.RightFoot);
r.leftUpperArm = anim.GetBoneTransform(HumanBodyBones.LeftUpperArm);
r.leftLowerArm = anim.GetBoneTransform(HumanBodyBones.LeftLowerArm);
r.leftHand = anim.GetBoneTransform(HumanBodyBones.LeftHand);
r.rightUpperArm = anim.GetBoneTransform(HumanBodyBones.RightUpperArm);
r.rightLowerArm = anim.GetBoneTransform(HumanBodyBones.RightLowerArm);
r.rightHand = anim.GetBoneTransform(HumanBodyBones.RightHand);
BipedRagdollCreator.Create(r, BipedRagdollCreator.Options.Default);
}
}
参考