Frame changes absolute position when size is changed

I was making a crosshair for my guns but when I am trying to make recoil the absolute position changes which I don’t want since if it changes the crosshair is inaccurate. → Also the crosshair markers don’t stay with the frame. Any help would be welcomed.

Seems like you are using “Fixed Positions” The Offset. Even if you change your monitor resolution everything will be messed up… If someone joins your game (me) and I use a phone or a different size of monitor than yours, I will have the crosshair in a wrong position.

First you need to parent those crosshair GUI correctly, and use Scale Size and Position for it. Not the Offset.
As you noticed it. The Size property, has Scale and Offset. Set Offset to 0, and use Scale Size for X and Y. Scale 1 means that the Frame covers all screen, Scale 0.5 it only covers the half, etc.
Place a scale sized GUI in the center of the screen. In that way any player will have the crosshair correctly aligned in the center of any device they are using.
After that, you can start checking that position issue you are experiencing.

1 Like

What should the scale be in the size since it covers the entire screen.

Scale 1 covers all screen, 0.5 the half… is intuitive. 0.2 would be a 1/5 of the screen. Use any size you want from 0 to 1. Idk try 0.01 and it will be very little. On X and Y of course, both

1 Like

Never mind I found the right size

Is there any way to fix the little crosshair marks from separating from the frame?

I cant clearly see the separation you meention on the pics you posted.
What I would do, is place all those components together into a frame, so, all components will keep its layout no matter if you move them or scale them.
Depends on the structure you are using, what is the child of what?

1 Like

I have the little marks with offset on size so that might be a problem.
Any other than the original size will not together. But if you can, could you help with the absolute size changing?

So, that little Gray box in the middle is the CrossFrame?
and the Cross its made by 4 little frames? Up, Down, L, R ?

give me a sec to test it. I usually would go with a .png image to create the cross and I would not use little frames to create it, just importing a .png. Let me check what happens with your approach

2 Likes

Yes you are correct.
characters

After trying it… yes. Its not a good way to use those little frames to create the crosshair. Why dont you use a .png image?
If you use an image and center it into the frame would be easier for you to keep it aligned!

Here’s a crosshair image for you to test it.

crosshair|500x500

1 Like

I never tried to make a crosshair before… Seems more tricky than I thought…

I think the best, in order all device sizes, and monitors works perfect, would be use some math, checking the size of the device and making the calculations in order to resize everything perfectly.

Another way that would be very easy, would be. Using an image like the one I sent you, using offset size for the image. Create a Frame of Scale 1, 1. And… use a UI grid layout to keep it perfect centered on all devices. The only problem I found with this, is that the crosshair will not resize. If a monitor is very big, the crosshair will look a little tiny, if the phone is very small, the crosshair will be a little big… Thats why, using some math, to resize the crosshair depending on the screen resolution will be perfect. meanwhile, this works acceptable

Thanks now the crosshair correlates with the frame and I will figure out the position situation unless you know a way. But anyways thank you.

A problem I noticed is that the position is not on the center of the objects. Its on the left upper corner.Thats why I used the UI grid layout. So automatically it get placed in the center of everything no matter the size of the screen

1 Like

I adjusted the grid layout so it would be at the center. Thank you.

1 Like