2D Vector environment

I am trying to set up a 2D vector environment, so that it looks like this


now to achieve this, I need to normalize the distance/size of my computer screen. If my monitor size is 1024 x 1024 Pixels, how can I turn that into a normalized 10x10 unit? What if the screen isn’t a perfect square?

Essentially, what I want is to get some sort of 10x10 or 100x100 2d environment based on my screen size.

I’ve thought of using math.clamp() to normalize the distance, but I’ve no clue how to deal with the screen being a rectangle.

I achieved the goal, here’s the finished product!

In the end I didn’t have to use clamp() all that much, most of it was creating the functions to convert a vector2(given in units) to udim, and a function to convert udim into vector2. It turned out pretty well! The 2D vector can be set to whichever unit system you like, such as 4x4 or 1000x1000

Would this be a ScreenGui?

:slight_smile: :slight_smile: :slight_smile: :slight_smile: :slight_smile: :slight_smile: :slight_smile:

UDim2s have an option for either using scale or offset for each direction. Scale is relative to the screen, while offset is in pure pixels.

So, if you wanted to create a frame that was 100 pixels by 100 pixels, its size would be UDim2.new(0, 100, 0, 100). You can then scale this just by multiplying that offset by a multiplier, and you would be done.

1 Like

Yes, I plan to use this along with GUI objects inside of a screenGui.

This worked, thanks. My next step is to normalize that square into given units (like 10, or 100) then I can create visual vectors using arguments like vec2(1,10), which would return actual measurements in scale/offset!

Just set the Frame’s size to (100,0,100,0) and then adjust the size to how you want it, making sure the x,y are both the same numbers. I don’t think you would need any scripting for that.