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

35 lines
896 B
C#
Raw Permalink 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 Look At")]
[Category("Animator")]
public class MecanimSetLookAt : ActionTask<Animator>
{
public BBParameter<GameObject> targetPosition;
public BBParameter<float> targetWeight;
protected override string info {
get { return "Mec.SetLookAt " + targetPosition; }
}
protected override void OnExecute() {
router.onAnimatorIK += OnAnimatorIK;
}
protected override void OnStop() {
router.onAnimatorIK -= OnAnimatorIK;
}
void OnAnimatorIK(ParadoxNotion.EventData<int> msg) {
agent.SetLookAtPosition(targetPosition.value.transform.position);
agent.SetLookAtWeight(targetWeight.value);
EndAction();
}
}
}