12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- using System;
- using RootMotion.FinalIK;
- using UnityEngine;
- [Serializable]
- public class HeightIKCtrlData : CCDIKCtrlData
- {
- public HeightIKCtrlData(CCDIK ccd_ik, Transform[] chain_bones, FullBodyIKCtrl ik_ctrl, bool weight_fade = true, bool attach_ik = false) : base(ccd_ik, chain_bones, ik_ctrl, weight_fade, attach_ik)
- {
- }
- public void CheckReachTarget()
- {
- if (!base.PointIK.IsIKExec || base.PointIK.BlendType == IKCtrlData.IKBlendType.IK_To_Detach)
- {
- return;
- }
- float num = Vector3.Distance(base.IKTarget.position, this.TargetBone.position);
- if (num <= 0.05f || (num > 1f && base.PointIK.BlendNow))
- {
- return;
- }
- int value = this.MyIKCtrl.TgtMaid.GetProp(MPN.sintyou).value;
- int value2 = base.PointIK.TgtMaid.GetProp(MPN.sintyou).value;
- if (this.m_EachOtherIK && value < value2)
- {
- IKCtrlData ikdata = base.PointIK.TgtMaid.IKCtrl.GetIKData(base.PointIK.Tgt_AttachName, false);
- if (base.PointIK.TgtMaid.IKCtrl.IsUpdateEnd)
- {
- ikdata.IKTarget.position += (this.TargetBone.position - base.IKTarget.position) * ikdata.PointIK.BlendWeight;
- base.PointIK.TgtMaid.IKCtrl.SolverUpdate();
- }
- }
- else if (!this.MyIKCtrl.DoHeightCover && !base.PointIK.BlendNow)
- {
- Vector3 vector = base.IKTarget.position - this.TargetBone.position;
- this.MyIKCtrl.BodyTarget.position += vector;
- foreach (IKCtrlData ikctrlData in this.MyIKCtrl.strIKDataPair.Values)
- {
- ikctrlData.SetTargetOffset(vector, false);
- }
- this.MyIKCtrl.BodyEffector.positionWeight = 1f;
- }
- this.MyIKCtrl.DoHeightCover = true;
- }
- public override void Update()
- {
- base.Update();
- this.CheckReachTarget();
- }
- }
|