You can also get it with Camera.ViewportSize. But this doesn’t solve Shedletsky’s problem.
We need some way to get either the DPI or (preferrably) the physical size of the display to allow better scaling for different devices in our games, or else we get problems like OP where gameplay might even suffer.
An iPhone 6 can be 401 ppi and a 27 inch 1080p screen can be 81 ppi.
So if I size my regions correctly for the phone, they are going to be way too big on the monitor.
More importantly, if I size my regions for the iPhone 6, they will also be too big on some android crap phone with 100 ppi that I can’t test on. Or they will be way too small on an android super phone. It seems like they go to ~600 ppi.
Couldn’t you scale it based on the width to height ratio of the screen, rather than the real-world scale of the display?
The height of the screen scales the viewport afaik. You might be able to figure out something from that.
local cam = workspace.CurrentCamera
local vp = cam.ViewportSize
local aspectRatio = vp.X/vp.Y
local hFactor = math.tan(math.rad(cam.FieldOfView/2))
local wFactor = hFactor * aspectRatio
We ran into this issue when trying to display emulated devices in Studio. It turns out there’s no universal way to determine this so your best bet is to prompt the user, probably by giving them a slider and adjusting it until something on screen matches a real-world object.
Not exactly sure what you mean, but there’s no major OS that directly exposes physical display density. There’s no real way for desktop OSes to know, Android only gives you a general idea, and iOS tries to refer to everything in “points” that loosely correspond to actual density. So iOS is the only one that gets anywhere close.