Skip to content

Instantly share code, notes, and snippets.

@jakevsrobots
Created June 7, 2013 17:39
Show Gist options
  • Save jakevsrobots/5730986 to your computer and use it in GitHub Desktop.
Save jakevsrobots/5730986 to your computer and use it in GitHub Desktop.
public float speed;
Vector3 targetPosition;
void Update() {
transform.position = Vector3.MoveTowards(transform.position, targetPosition, Time.deltaTime * speeed);
if(Vector3.Distance(transform.position, targetPosition) < 0.1f) {
targetPosition = Random.insideUnitSphere * 10;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment