Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void SwipeTile(){
- if (Mathf.Abs(xPosition - transform.position.x) > .1){
- //Move towards the target
- Vector3 tempPosition = new Vector2(xPosition, transform.position.y);
- transform.position = Vector2.Lerp(transform.position, tempPosition, .4f
- }
- else{
- //Directly set the position
- tempPosition = new Vector2(xPosition, transform.position.y);
- transform.position = tempPosition;
- grid.tiles[column, row] = this.gameObject;
- }
- if (Mathf.Abs(yPosition - transform.position.y) > .1){
- //Move towards the target
- Vector3 tempPosition = new Vector2(transform.position.x, yPosition);
- transform.position = Vector2.Lerp(transform.position, tempPosition, .4f);
- }
- else{
- //Directly set the position
- Vector3 tempPosition = new Vector2(transform.position.x, yPosition);
- transform.position = tempPosition;
- grid.tiles[column, row] = this.gameObject;
- }
- }
- //.....//
- void Update(){
- xPosition = (column * _grid.offset.x) + _grid.startPosition.x;
- yPosition = (row * _grid.offset.y) + _grid.startPosition.y;
- SwipeTile();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement