Unity 2D: Positioning 2D sprites relative to the camera

I am making an endless runner where I generate obstacles on the bottom right corner of the screen right above the platform the player is running on.

What I am trying to do is position the obstacles relative to the camera so that, no matter what screen size the game is played on, the obstacles are always appearing at the appropriate position at the bottom right.

I’m unsure about grabbing a reference to the camera, I currently have:

Camera camera = Camera.main;

I’m not sure where to go from there and how to get the desired result. Any help is much appreciated!

P.S. Please correct me if this isn’t the proper way of doing this.

Here is a short vid on how to calculate screen bounds. You can use the calculations and change it to instantiate things where you want like the bottom right of the screen, no matter the screen.

Could probably look like:

Vector2 screenBounds;
public GameObject obj;

void Start()
{
        screenBounds = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, Camera.main.transform.position.z));
}
void Spawn() //spawn thing at bottom right of screen
{
        GameObject obstacle = Instantiate(obj, new Vector2(screenBounds.x, -screenBounds.y), Quaternion.identity);
}