// Start is called before the first frame update void Start() { if (!premaidRoot) { // 未指定ならモデルのルートにこのスクリプトがアタッチされているものとする premaidRoot = transform; } if (premaidRoot != null) { _joints = premaidRoot.GetComponentsInChildren <ModelJoint>(); } // 左腕IKソルバを準備 leftArmIK = new ArmIK(); leftArmIK.isRightSide = false; leftArmIK.shoulderPitch = GetJointById("04"); leftArmIK.upperArmRoll = GetJointById("0B"); leftArmIK.upperArmPitch = GetJointById("0F"); leftArmIK.lowerArmRoll = GetJointById("13"); leftArmIK.handPitch = GetJointById("17"); leftArmIK.handTarget = leftHandTarget; leftArmIK.elbowTarget = leftElbowTarget; leftArmIK.Initialize(); leftElbowTarget = leftArmIK.elbowTarget; // 自動生成されていたら、controller側に代入 leftHandTarget = leftArmIK.handTarget; // 自動生成されていたら、controller側に代入 // 右腕IKソルバを準備 rightArmIK = new ArmIK(); rightArmIK.isRightSide = true; rightArmIK.shoulderPitch = GetJointById("02"); rightArmIK.upperArmRoll = GetJointById("09"); rightArmIK.upperArmPitch = GetJointById("0D"); rightArmIK.lowerArmRoll = GetJointById("11"); rightArmIK.handPitch = GetJointById("15"); rightArmIK.handTarget = rightHandTarget; rightArmIK.elbowTarget = rightElbowTarget; rightArmIK.Initialize(); rightElbowTarget = rightArmIK.elbowTarget; // 自動生成されていたら、controller側に代入 rightHandTarget = rightArmIK.handTarget; // 自動生成されていたら、controller側に代入 // 頭部IKソルバを準備 headIK = new HeadIK(); headIK.neckYaw = GetJointById("05"); headIK.headPitch = GetJointById("03"); headIK.headRoll = GetJointById("07"); headIK.headTarget = headTarget; headIK.Initialize(); headTarget = headIK.headTarget; // 自動生成されていたら、controller側に代入 // 左脚IKソルバを準備 leftLegIK = new LegIK(); leftLegIK.isRightSide = false; leftLegIK.upperLegYaw = GetJointById("08"); leftLegIK.upperLegRoll = GetJointById("0C"); leftLegIK.upperLegPitch = GetJointById("10"); leftLegIK.kneePitch = GetJointById("14"); leftLegIK.anklePitch = GetJointById("18"); leftLegIK.footRoll = GetJointById("1C"); leftLegIK.footTarget = leftFootTarget; leftLegIK.Initialize(); leftFootTarget = leftLegIK.footTarget; // 右脚IKソルバを準備 rightLegIK = new LegIK(); rightLegIK.isRightSide = true; rightLegIK.upperLegYaw = GetJointById("06"); rightLegIK.upperLegRoll = GetJointById("0A"); rightLegIK.upperLegPitch = GetJointById("0E"); rightLegIK.kneePitch = GetJointById("12"); rightLegIK.anklePitch = GetJointById("16"); rightLegIK.footRoll = GetJointById("1A"); rightLegIK.footTarget = rightFootTarget; rightLegIK.Initialize(); rightFootTarget = rightLegIK.footTarget; }