Skip to content

Instantly share code, notes, and snippets.

@eddietree
Last active January 29, 2016 18:07
Show Gist options
  • Save eddietree/a59e10f9fa9395bdf7ae to your computer and use it in GitHub Desktop.
Save eddietree/a59e10f9fa9395bdf7ae to your computer and use it in GitHub Desktop.
for isaac
// Problem: you are making an AI that goes to a location, stops for 1 second, then starts again
IEnumerator DoCoroutine() {
// go to a location
Vector3 randomDestination = GetRandomLocation();
float walkTotalTime = 1.0;
// walk towards
float walkTimer = 0.0;
while( walkTimer < walkTotalTime ) {
walkTimer -= Time.delta;
position.MoveTowards(position, randomDestination, Time.delta);
yield return null;
}
// sleep one second
yield return new WaitForSeconds(1.0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment