change: added repath timer to "new path" task
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user