Finding the corners of the screen to world point position

Hi, I am trying to figure out how to get the world positions of the corners of the player’s screen, How would I do this? I’ve looked at other posts but cant seem to figure it out.

Thank you

3 Likes

Something like this

local workspace = game:GetService("Workspace")

local camera = workspace.CurrentCamera

local vs = camera.ViewportSize

function getworldpoint(x,y)
	local ray = camera:ScreenPointToRay(x, y)
	local worldposition = ray.Origin + ray.Direction * 1

	return worldposition
end

getworldpoint(1,1) --TopLeft

getworldpoint(vs.X,vs.Y) --BottomRight

getworldpoint(vs.X,1) --TopRight

getworldpoint(1,vs.Y) --BottomLeft
5 Likes

Alright this is kind of what i was looking for, how would I go about making this so it stays at that same angle that the camera is looking at and goes down to y 0

1 Like

Sorry ignore this I mixed up our dm’s with the post

So look at this image i just drew up as a representation


The black box represents the cameras view, the red points represent the points based off of the script you wrote above the green points is where I want them to actually be, so they keep that angle all the way down to Y0, but the camera will be changing its height a bit so it cant be hardcoded.

So do you want it so the points can’t go under y 0 zero?

yes exactly, the camera looks down on the map and I need the points to be at the corners or the players screen at y0 but obviously cant just set the points y to 0 because then the position of those points wouldn’t be what the camera views

I don’t know how to do that, I’ll try and work it out though.

akright thank you

thirtycharacters