How would I go about getting all the parts that is within view of a players screen?
Thanks.
How would I go about getting all the parts that is within view of a players screen?
Thanks.
Sorry for a year(!)'s delay, but ROBLOX just released a Camera update:
local pos, vis = workspace.CurrentCamera:WorldToScreenPoint(workspace.Part.Position)
if vis then
print("Point is Visible on screen!")
end
You can use this to loop through every part you care about to see if it's Visible. On it's own, this isn't perfect, but it's a good start.
Not quite sure on how the FieldOfView property works for Camera's, but couldn't you cast a bunch of ray's within a (FieldOfView?) degree radius to try and find every part? After all, even if you could get Region3 to work or something like MrNicNac suggested, you would end up with parts that were hidden behind walls as well. The only way to counter that is to use raycasting. But if that's fine, then you can try this...
This discussion is preserved as it was. New answers, comments, and votes are closed.
3 comments
Anyone?
Easier said than done. I'm interested to know if anyone has a solution to this using Region3 (even with some inaccuracy because of the lack of rotated Region3s). Currently, the only method I can think of is gathering all the BasePart descendants of Workspace, and then checking individually against a function that transforms the 3D coordinates to 2D counter-parts. I have a function to do that if yo
Yea, I was thinking about using Region3, but then I remembered you can't rotate Region3 areas. Also, did you mean to answer or post a comment? Your post was cut off :P