AspectRatioContainer and positioning of objects

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Maenny

I am currently working on a scene with an AspectRatioContainer (Stretch Mode: Cover) in combination with a TextureRect (expand true). I configured the nodes so that a background image will always cover the screen, no matter what aspect ratio the user needs. So far this is working fine.

What I would like to do now, is to add some objects that should stay with the backgroud. Think of a background showing a caste with towers, and I want to place animated flags on top of the towers. My problem is now, that the background image adjusts in a way that the objects do not. I need to be able to “ancor” the objects to a certain point on the TextureRect.

I believe that this is not possible with any settings on the objects. Instead, I would have to re-adjust position and scale of the objects. But I am currently struggling to find the correct mathematical approach, as I am not sure what parameters are influencing these objects. Maybe someone has an idea?

In the ProjectSettings/Display/Window/Stretch I am using 2d-Mode and Aspect expand.