IndieGame/client/Assets/ParadoxNotion/NodeCanvas/Tasks/Actions/GameObject/LookAt.cs
DOBEST\zhaoyingjie f242607587 初始化工程
2024-10-11 10:12:15 +08:00

33 lines
772 B
C#

using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Actions
{
[Category("GameObject")]
public class LookAt : ActionTask<Transform>
{
[RequiredField]
public BBParameter<GameObject> lookTarget;
public bool repeat = false;
protected override string info {
get { return "LookAt " + lookTarget; }
}
protected override void OnExecute() { DoLook(); }
protected override void OnUpdate() { DoLook(); }
void DoLook() {
var lookPos = lookTarget.value.transform.position;
lookPos.y = agent.position.y;
agent.LookAt(lookPos);
if ( !repeat )
EndAction(true);
}
}
}