IndieGame/client/Assets/ParadoxNotion/NodeCanvas/Tasks/Actions/Animator/MecanimSetIK.cs

37 lines
931 B
C#
Raw Normal View History

2024-10-11 10:12:15 +08:00
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Actions
{
[Name("Set IK")]
[Category("Animator")]
public class MecanimSetIK : ActionTask<Animator>
{
public AvatarIKGoal IKGoal;
[RequiredField]
public BBParameter<GameObject> goal;
public BBParameter<float> weight;
protected override string info {
get { return "Set '" + IKGoal + "' " + goal; }
}
protected override void OnExecute() {
router.onAnimatorIK += OnAnimatorIK;
}
protected override void OnStop() {
router.onAnimatorIK -= OnAnimatorIK;
}
void OnAnimatorIK(ParadoxNotion.EventData<int> msg) {
agent.SetIKPositionWeight(IKGoal, weight.value);
agent.SetIKPosition(IKGoal, goal.value.transform.position);
EndAction();
}
}
}