Skip to content

Commit

Permalink
trying to fiix wander error
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Frowen committed Mar 29, 2021
1 parent cb83566 commit 462ceb2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Assets/Mirage/Samples~/InterestManagement/Scripts/Wander.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using System.Collections;
using UnityEngine;
using UnityEngine.AI;

Expand All @@ -10,11 +9,17 @@ public class Wander : MonoBehaviour
public NavMeshAgent agent;

public Bounds bounds;
private Coroutine coroutine;

// Start is called before the first frame update
public void StartMoving()
{
StartCoroutine(Move());
coroutine = StartCoroutine(Move());
}

private void OnDestroy()
{
StopCoroutine(coroutine);
}

public IEnumerator Move()
Expand All @@ -31,6 +36,7 @@ public IEnumerator Move()
agent.destination = position;

yield return new WaitForSeconds(Random.Range(1.0f, 5.0f));
if (!agent.isActiveAndEnabled) { yield break; }
}
}
}
Expand Down

0 comments on commit 462ceb2

Please sign in to comment.