Second Camera Position on Viewport to UI Element Position on Screen

Hello, I have a UI image that follows the player on the screen. I also have a second camera (like a mini map). How would I set the rect position of the second camera to the UI image position on the screen so that wherever the UI image goes in the screen, the second camera will follow. Thanks

Ok, I found that you use ScreenToViewportPoint and pass through the UI element anchored position, it will line up properly. But I had to set the UI element’s anchored position to the bottom left.

public Canvas canvas;
public RectTransform fitViewport;

	void Update()
	{
		Camera.main.pixelRect = RectTransformUtility.PixelAdjustRect(fitViewport, canvas);
	}