hey all ! I have a moving GUI element, displayed in the gif here:

I want to keep it to the closest edge point of where the GUI actually is so it doesn’t go out of frame, can anyone point me in the right direction ? thanks !
To be completely honest, I’m not sure what’s the best way to explain it to you; I just use intuition, size and position values: Anchor points matter a lot, too.
Here’s an example image. Sorry for its crudeness.
(The 0 and 1 values correspond to the values of the positions of the edges of the UI. Let’s assume it’s a frame and that both A and B have anchor points of (0.5,0.5) for the sake of the demonstration).
When a UI element (like a Frame) is near an edge where its corresponding position value is 1, it will “touch” the edge when its position equals (1 - (size corresponding to the edge’s axis)). Inversely for the opposite edges, the UI element will touch when its corresponding position value is its corresponding size.
For example, a Frame with size (0.1, 0, 0.1, 0) with anchor point (0.5,0.5) will touch the bottom wall when its Y (scale) position equals 0.9 (1 - 0.1).
This logic should also work with Offset sizes too. Hope this helps!
this helps a lot, thank you very much !
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
