Advertisement
Guest User

Untitled

a guest
Apr 4th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. public void sTrack()
  2. {
  3.  
  4.  
  5. if (path == null || GlobalLastSighting != lastplayersight.playerPosition)
  6. {
  7.  
  8. GlobalLastSighting = lastplayersight.playerPosition;
  9. seeker.StartPath(transform.position, lastplayersight.playerPosition, OnPathComplete);
  10.  
  11. //We have no path to move after yet
  12. Debug.Log("-----NO PATH---");
  13. return;
  14. }
  15.  
  16. if (Vector3.Distance(transform.position, path.vectorPath[currentWaypoint]) < nextWaypointDistance)
  17. {
  18. currentWaypoint++;
  19. }
  20.  
  21. if (currentWaypoint >= path.vectorPath.Count)
  22. {
  23. waitTrackTimer += Time.deltaTime;
  24.  
  25. if (waitTrackTimer >= waitAfterTrack) {
  26. Debug.Log("End Of Path Reached");
  27. if (!seePlayer) lastplayersight.playerPosition = lastplayersight.playerPositionDefault;
  28. if (!seePlayer) personalLastSighting = lastplayersight.playerPositionDefault;
  29. GlobalLastSighting = lastplayersight.playerPosition;
  30. currentWaypoint = 0;
  31. path = null;
  32. return;
  33. }
  34. }
  35.  
  36. if (currentWaypoint < path.vectorPath.Count)
  37. rb.AddForce((path.vectorPath[currentWaypoint] - transform.position) * TrackSpeed);
  38.  
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement