Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. Transform[] patrolpoints;
  2. int currentPatrolPoint;
  3.  
  4. void update() {
  5. if(transform.position == patrolpoints[currentPatrolPoint].position) {
  6. currentPatrolPoint++;
  7. }
  8. if(currentPatrolPoint > patrolpoints.Length) {
  9. currentPatrolPoint = 0;
  10. }
  11.  
  12. // the the moving part here accessing the current
  13. transform.position = Vector2.moveTowards(transform.position, patrolpoints[currentPatrolPoint], speed * Time.deltaTime);
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement