Advertisement
Guest User

Untitled

a guest
Aug 24th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. void SwipeTile(){
  2. if (Mathf.Abs(xPosition - transform.position.x) > .1){
  3. //Move towards the target
  4. Vector3 tempPosition = new Vector2(xPosition, transform.position.y);
  5. transform.position = Vector2.Lerp(transform.position, tempPosition, .4f
  6. }
  7. else{
  8. //Directly set the position
  9. tempPosition = new Vector2(xPosition, transform.position.y);
  10. transform.position = tempPosition;
  11. grid.tiles[column, row] = this.gameObject;
  12. }
  13.  
  14. if (Mathf.Abs(yPosition - transform.position.y) > .1){
  15. //Move towards the target
  16. Vector3 tempPosition = new Vector2(transform.position.x, yPosition);
  17. transform.position = Vector2.Lerp(transform.position, tempPosition, .4f);
  18. }
  19. else{
  20. //Directly set the position
  21. Vector3 tempPosition = new Vector2(transform.position.x, yPosition);
  22. transform.position = tempPosition;
  23. grid.tiles[column, row] = this.gameObject;
  24. }
  25. }
  26.  
  27. //.....//
  28.  
  29. void Update(){
  30. xPosition = (column * _grid.offset.x) + _grid.startPosition.x;
  31. yPosition = (row * _grid.offset.y) + _grid.startPosition.y;
  32. SwipeTile();
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement