change: added repath timer to "new path" task

This commit is contained in:
Chris
2025-12-03 17:29:45 -05:00
parent b19421adfc
commit 14ea2c64dc
3 changed files with 16 additions and 6 deletions

View File

@@ -11,6 +11,9 @@ namespace Reset.Units {
public class SetNewPathfindingPath : ActionTask<UnitPathfinding>{
public BBParameter<GameObject> target;
public bool useTimer;
public BBParameter<float> timeToRepath;
//Use for initialization. This is called only once in the lifetime of the task.
//Return null if init was successfull. Return an error string otherwise
protected override string OnInit() {
@@ -27,7 +30,11 @@ namespace Reset.Units {
//EndAction can be called from anywhere.
protected override void OnExecute() {
agent.seeker.StartPath(agent.transform.position, target.value.transform.position, OnPathComplete);
if (useTimer) {
return;
}
EndAction(true);
}
@@ -39,7 +46,10 @@ namespace Reset.Units {
//Called once per frame while the action is active.
protected override void OnUpdate() {
if (useTimer && elapsedTime > timeToRepath.value) {
agent.seeker.StartPath(agent.transform.position, target.value.transform.position, OnPathComplete);
EndAction();
}
}
//Called when the task is disabled.