Move an object depending on an animated sprite

I have a green animated rectangle and another rectangle (blue). I want the blue rectangle to stay on the green one when he’s moving horizontally.

6510268--733594--upload_2020-11-10_23-57-36.png

Setting the blue rectangle as a child to the animated rectangle won’t work for me because of the circle collider. It tells me when the animation should trigger.

I can somehow fix this by adding the circle collider to a child (and move the logic scripts here) and add a rectangle collider on top of the green rectangle so i can preciselly detect when user isn’t on the platform, but it takes time and i want an easier method. Is there any?

6510268--733594--upload_2020-11-10_23-57-36.png

put this code on the green rectangl

public GameObject bluRectangl;
public float verticaldistance;

void Update(){

blurRectangl.transform.position = new vector3(transform.position.x, transform.position.y + verticaldistance, transform.position.z);


}