Confusion about coordinate systems

I’m confused about Unity’s coordinate system. I’m working on a game that is only UI (everything is an Image/RawImage on a canvas).

My screen size is 1920x1080. I set a Vector3 to place an image slightly off screen through RectTransform, like this:

airportOffScreenLocation = new Vector3(1060, 0, 0);
plane.GetComponent<RectTransform>().anchoredPosition = airportOffScreenLocation;

With this code, Unity seems to put 0, 0 as the middle of the screen. So this code places the image about 100 pixels to the right of the screen.

But then I try to move the plane to the exact same position with this code (using DOTween):

        plane.transform.DOMove(airportOffScreenLocation,2f);

Instead of the plane staying stationary, it flies to a point on the screen. DOTween seems to put 0, 0 at the top left of the screen.

Does anyone know why there the coordinate system is different in these two cases?

UI and the World don’t have a one to one conversion like that.

I’m assuming you have your UI in a canvas object set to either Screen space or Camera screen etc. Lets go over all the options for a bit for the Canvas.

When its a “World” Canvas, it indeed matches, with 1 “pixel” / size being 1 unit in the 3D space, this is typically used for a display in your world.

Camera screen puts your canvas in the frustum of your Camera X distance away from the camera. so whether your UI is 500 or 3000 “pixels” it will all be cramped in the space defined by the camera frustum.

lastly screen space will make the UI match your actual display screen so it will again fit however many “pixels” you define in some space which matches to your screen.

There exist conversion methods to be used, directly between viewport, screen and world space:

Good luck.