public Vector3 worldToUISpace(Canvas parentCanvas, Vector3 worldPos)
The key for moving a UI object is the RectTransformUtility.ScreenPointToLocalPointInRectangle function which converts the screen point to ui rectangle local point. It takes a the Canvas of the UI as parameter then the position you want to convert to UI position which in your case is the variable. This simple function below converts world position to UI space. In another way, this can be described as converting world point to UI point. You want to make a UI Object(Image) follow a GameObject is a SpriteRenderer or MeshRenderer.