1
This commit is contained in:
@@ -15,6 +15,7 @@ namespace NodeCanvas.Tasks.Actions
|
||||
public BBParameter<GameObject> target;
|
||||
public BBParameter<float> speed = 4;
|
||||
public BBParameter<float> keepDistance = 0.1f;
|
||||
public BBParameter<bool> waitUntilFinish = false;
|
||||
|
||||
private Vector3? lastRequest;
|
||||
|
||||
@@ -29,16 +30,21 @@ namespace NodeCanvas.Tasks.Actions
|
||||
EndAction(true);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected override void OnUpdate() {
|
||||
if ( target.value == null ) { EndAction(false); return; }
|
||||
var pos = target.value.transform.position;
|
||||
if ( lastRequest != pos ) {
|
||||
if ( !agent.SetDestination(pos) ) {
|
||||
if (lastRequest != pos)
|
||||
{
|
||||
if (!agent.SetDestination(pos))
|
||||
{
|
||||
EndAction(false);
|
||||
return;
|
||||
}
|
||||
if (waitUntilFinish.value == false)
|
||||
EndAction(true);
|
||||
}
|
||||
|
||||
lastRequest = pos;
|
||||
@@ -46,11 +52,13 @@ namespace NodeCanvas.Tasks.Actions
|
||||
if ( !agent.pathPending && agent.remainingDistance <= agent.stoppingDistance + keepDistance.value ) {
|
||||
EndAction(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected override void OnPause() { OnStop(); }
|
||||
protected override void OnStop() {
|
||||
if ( agent.gameObject.activeSelf ) {
|
||||
if ( agent.gameObject.activeSelf && agent.isOnNavMesh && waitUntilFinish.value) {
|
||||
agent.ResetPath();
|
||||
}
|
||||
lastRequest = null;
|
||||
|
Reference in New Issue
Block a user