Advertisement
Guest User

Untitled

a guest
May 24th, 2015
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. if (Mathf.Sqrt(Mathf.Pow(xDist, 2) + Mathf.Pow(yDist, 2)) <= 80f)
  2. {
  3. xDist = follow.transform.position.x - transform.position.x;
  4. yDist = follow.transform.position.y - transform.position.y;
  5. }
  6. else {
  7. //transform.position = Vector3.Lerp (transform.position)
  8. transform.position = new Vector3(Mathf.RoundToInt(follow.transform.position.x - xDist), Mathf.RoundToInt(follow.transform.position.y - yDist), transform.position.z);
  9. if (xDist > 0)
  10. {
  11. xDist -= 0.25f * Time.deltaTime * 60f;
  12. }
  13. else if (xDist < 0)
  14. {
  15. xDist += 0.25f * Time.deltaTime * 60f;
  16. }
  17. if (yDist > 0)
  18. {
  19. yDist -= 0.25f * Time.deltaTime * 60f;
  20. }
  21. else if (yDist < 0)
  22. {
  23. yDist += 0.25f * Time.deltaTime * 60f;
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement