using RootMotion.FinalIK; using UnityEngine; [CreateAssetMenu(menuName = "Data/RodActionCurve", fileName = "RodActionCurve")] public class RodActionCurve : ScriptableObject { public AnimationCurve curve; private void InjectCurveIntoRodInPlayerHand() { if (!Application.isPlaying) { Debug.LogWarning("Cannot inject curve. The game is not running."); return; } FPlayer fPlayer = Object.FindObjectOfType(); if (fPlayer == null) { Debug.LogWarning("FPlayer not found in the scene."); return; } if (fPlayer.currentRod == null) { Debug.LogWarning("FPlayer's currentRod is null."); return; } CCDIK component = fPlayer.currentRod.GetComponent(); if (component == null) { Debug.LogWarning("CCDIK component not found on the currentRod."); return; } int num = component.solver.bones.Length; for (int i = 0; i < num; i++) { float time = (float)i / (float)(num - 1); float weight = curve.Evaluate(time); component.solver.bones[i].weight = weight; } } }