LimbIKData.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System;
  2. using System.Linq;
  3. using RootMotion.FinalIK;
  4. using UnityEngine;
  5. public abstract class LimbIKData : IKCtrlData
  6. {
  7. public LimbIKData(FullBodyIKCtrl ik_ctrl, FBIKChain chain, IKMappingLimb ik_mapping, Transform tgt_bone, bool use_old = false) : base(ik_ctrl, tgt_bone, use_old, false)
  8. {
  9. this.Chain = chain;
  10. this.IKMapping = ik_mapping;
  11. this.m_ChainBones = (from node in this.Chain.nodes
  12. select node.transform).ToArray<Transform>();
  13. }
  14. public override void SetPullState(bool pull_on)
  15. {
  16. if (this.m_OrijinPull < 0f)
  17. {
  18. this.m_OrijinPull = this.Chain.pull;
  19. }
  20. if (pull_on)
  21. {
  22. this.Chain.pull = this.m_OrijinPull;
  23. }
  24. else
  25. {
  26. this.Chain.pull = 0.1f;
  27. }
  28. }
  29. public override void TagetTransCpy()
  30. {
  31. base.TagetTransCpy();
  32. if (this.m_IsUpperBody)
  33. {
  34. this.IKMapping.weight = 0f;
  35. }
  36. }
  37. public override void ApplyIKSetting()
  38. {
  39. base.ApplyIKSetting();
  40. if (this.m_IsUpperBody)
  41. {
  42. this.IKMapping.weight = Mathf.Max(this.IKMapping.weight, Mathf.Max(this.PositionWeight, this.RotationWeight));
  43. }
  44. }
  45. public readonly FBIKChain Chain;
  46. public readonly IKMappingLimb IKMapping;
  47. protected bool m_IsUpperBody;
  48. protected float m_OrijinPull = -1f;
  49. }