Advertisement
Guest User

Untitled

a guest
May 11th, 2022
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. IEnumerator MoveRandomPos()
  2. {
  3. yield return new WaitForSeconds(Random.Range(4f, 7f));
  4.  
  5. StartCoroutine(MoveRandomPos());
  6.  
  7. RaycastHit hit;
  8. Ray ray = new Ray(transform.position, Quaternion.Euler(0f, Random.Range(0f, 360f), 0f) * transform.forward);
  9.  
  10. /*Debug.DrawRay(transform.position, ray.direction, Color.red, 3f);*/
  11.  
  12. if (Physics.Raycast(ray, out hit))
  13. {
  14. if (hit.distance > 2f)
  15. {
  16. nav.SetDestination(ray.direction);
  17. }
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement