using System; using RootMotion.FinalIK; using UnityEngine; [Serializable] public class ShoulderThighIKCtrl : ALimbIKCtrl { public ShoulderThighIKCtrl(IKEffector root_effector, FBIKChain chain, IKMappingLimb ik_mapping, FullBodyIKMgr ik_ctrl, FullBodyIKMgr.IKEffectorType effector_type) : base(ik_ctrl, chain, ik_mapping, effector_type) { this.effector = root_effector; this.effector.target = base.constraintTarget; base.isUpperBody = (effector_type == FullBodyIKMgr.IKEffectorType.UpperArm_L || effector_type == FullBodyIKMgr.IKEffectorType.UpperArm_R); } public override bool isLeft { get { return this.effectorType == FullBodyIKMgr.IKEffectorType.UpperArm_L || this.effectorType == FullBodyIKMgr.IKEffectorType.Thigh_L; } } public override ALimbIKCtrl pairIK { get { FullBodyIKMgr.IKEffectorType effector_type; if (base.isUpperBody) { effector_type = ((!this.isLeft) ? FullBodyIKMgr.IKEffectorType.UpperArm_L : FullBodyIKMgr.IKEffectorType.UpperArm_R); } else { effector_type = ((!this.isLeft) ? FullBodyIKMgr.IKEffectorType.Thigh_L : FullBodyIKMgr.IKEffectorType.Thigh_R); } return this.myIKMgr.GetIKCtrl(effector_type); } } public ElbowKneeIKCtrl elbowKneeCtrl { get; private set; } public HandFootIKCtrl handFootCtrl { get; private set; } public void SetChain(HandFootIKCtrl handfoot_data, ElbowKneeIKCtrl elbowknee_data) { this.handFootCtrl = handfoot_data; this.elbowKneeCtrl = elbowknee_data; this.ChainChildCtrl = elbowknee_data; } public override void ApplyIKSetting() { this.BackLocalPos = base.bone.localPosition; base.ApplyIKSetting(); } public override void OnPostIKUpdate() { base.OnPostIKUpdate(); base.bone.localPosition = this.BackLocalPos; } protected override void OnPostSetPositionWeight(float val) { if (this.IsPullBody) { this.effector.positionWeight = val; } } protected override void OnPostSetRotationWeight(float val) { if (this.IsPullBody) { this.effector.rotationWeight = val; } } public readonly IKEffector effector; private Vector3 BackLocalPos = Vector3.zero; }