duck

duck

Jun 2nd, 2010
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var targetOffsetDirection = (transform.position - target.position).normalized;
  2. var idealPosition = target.position + targetOffsetDirection * safeDistance;
  3. var directMoveDirection = (idealPosition - transform.position).normalized;
  4. var perpendicularMoveDirection = new Vector3(-directMoveDirection.z, 0, directMoveDirection.x);
  5. var zigzag = Mathf.PingPong(Time.time, 2) - 1;
  6. var moveDirection = directMoveDirection + perpendicularMoveDirection * zigzagFactor;
Advertisement
Add Comment
Please, Sign In to add comment