private IEnumerator Roam() { while (true) { yield return(new WaitForSeconds(UnityEngine.Random.value * 10.0f + 0.5f)); if (IsInteracting) { Debug.LogError("Should have stopped this coroutine by now"); } if (UnityEngine.Random.value < 0.2f) { SelectableObject randomObject = GetRandomAvailableSelectableObject(); if (randomObject != null) { SelectedObject = randomObject; IsInteracting = true; Interaction randomInteraction = SelectedObject.GetRandomNpcInteraction(); SelectedInteraction = randomInteraction; yield return(null); } } Destination = GetRandomLocation(); } }