how can my move a obect alon with the player

check the bellow pic. the green one is my player and the red one is obstacle when i tap the player has to come along with the obstacle .
am doing Lerp for the movement of player whenver it collides am making the obstacle as a child to the player. it done the job job but not properly.

i mean some overlapping is there like in the 2nd fig. because of the speed it is going like that.

how can i do it.

Okay, I think I understood the mechanics. Now, what is the problem? What do you mean by “overlapping”?

What I would do to move things in a 2D game is to have a two-dimensional int array (the field) which knows where the player and the obstacles are. For example 0 means it is empty, 1 means it is an obstacle, 2 the player.

Now I would create some Instances for my Obstacles and my Player (GameObjects with a script). When I tap for example, I can check which Obstacles or Player are in the tapped line, calculate where they need to go by checking if there are other objects in the way and call a Obstacle.move(int x, int y); function on the Obstacles and Player respectively to tell them where to go (they can lerp it nicely on their own Update functions). After that, just update your field array where it is needed.

Does that help or is there another problem?

thanks again @ RyFridge
am already did that what you said above.By using the above concept there is non uni sync between the player and obstacle.i mean player move with one speed and the obstacle move another speed . the only solution solution is whenever it is colliding make the obstacle as child.

my problem(overlapping) is solved .what i did is whenever it(obstacle) is colliding with the player am making it as a child to the player and am giving suitable position to the obstacle.

thanks,