using System; using System.Linq; using RootMotion.FinalIK; using UnityEngine; [Serializable] public class FABRIKCtrlData : IKCtrlData { public FABRIKCtrlData(FABRIK fabr_ik, Transform[] chain_bones, FullBodyIKCtrl ik_ctrl, bool attach_ik = false) : base(ik_ctrl, chain_bones.Last(), false, attach_ik) { this.FABRIK = fabr_ik; this.FABRIK.fixTransforms = false; this.IKSolver.target = base.IKTarget; this.IKSolver.useRotationLimits = false; this.IKSolver.maxIterations = 4; this.IKSolver.Initiate(chain_bones[0]); this.IKSolver.SetChain(chain_bones, chain_bones[0]); this.FABRIK.enabled = false; this.m_ForceIKEnable = false; } public IKSolverFABRIK IKSolver { get { return this.FABRIK.solver; } } public override Transform[] ChainBones { get { return (from bone in this.IKSolver.bones select bone.transform).ToArray(); } } public override float PositionWeight { get { return this.IKSolver.IKPositionWeight; } set { this.IKSolver.IKPositionWeight = value; } } public override float RotationWeight { get; set; } public override void Update() { this.FABRIK.solver.Update(); if (base.RotateIK.IsIKExec) { this.TargetBone.rotation = Quaternion.Lerp(this.TargetBone.rotation, base.IKTarget.rotation, this.RotationWeight); } } public readonly FABRIK FABRIK; }