Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. void LateUpdate()
  2. {
  3. //Vector3 targetPosition = new Vector3(target.position.x, target.position.y, transform.position.z);
  4. //targetPosition.x = Mathf.Clamp(targetPosition.x, minPosition.x, maxPosistion.x);
  5. //targetPosition.y = Mathf.Clamp(targetPosition.y, minPosition.y, maxPosistion.y);
  6.  
  7. // transform.position = Vector3.Lerp(transform.position, targetPosition, smoothing);
  8.  
  9. if (transform.position != target.position)
  10. {
  11. Vector3 targetPosition = new Vector3(target.position.x,
  12. target.position.y,
  13. transform.position.z);
  14.  
  15. if (Map.currentMap == 0)
  16. {
  17.  
  18. targetPosition.x = Mathf.Clamp(targetPosition.x, VillageBounds.bounds.min.x, VillageBounds.bounds.max.x);
  19. targetPosition.y = Mathf.Clamp(targetPosition.y, VillageBounds.bounds.min.y, VillageBounds.bounds.max.y);
  20. }
  21. else if (Map.currentMap == 1)
  22. {
  23. targetPosition.x = Mathf.Clamp(targetPosition.x, MineAreaBounds.bounds.min.x, MineAreaBounds.bounds.max.x);
  24. targetPosition.y = Mathf.Clamp(targetPosition.y, MineAreaBounds.bounds.min.y, MineAreaBounds.bounds.max.y);
  25. }
  26. else if(Map.currentMap == 2)
  27. {
  28. targetPosition.x = Mathf.Clamp(targetPosition.x, WABounds.bounds.min.x, WABounds.bounds.max.x);
  29. targetPosition.y = Mathf.Clamp(targetPosition.y, WABounds.bounds.min.y, WABounds.bounds.max.y);
  30. }
  31. else
  32. {
  33. transform.position = targetPosition;
  34.  
  35. }
  36.  
  37. transform.position = Vector3.Lerp(transform.position, targetPosition, smoothing);
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement