How to set an object'a position relative to screen?

Hi everyone, I wanted to add a rectangle on the screen, so that it is in the middle of the screen(not the scene). I tried using normal positions first. But it didn’t work, so I tried camera relative positions but it seems that camera’s X and Y don’t go below zero. Can anyone help me with this?

In the screenshot, X stands for CameraX, Y stands for CameraY and CX and CY stand for camera centerX and centerY respectively.

The camera’s x/y and centerX / centerY properties are the on-screen position of its viewport. The location of the world at which it’s looking is in the scrollX and scrollY properties.

If you want to fix an object to the camera set its scroll factor to 0 with setScrollFactor(0). For more substantial objects, it might be a better idea to use a separate scene.

3 Likes

Thanks, that helped a lot!