I’m creating a “Region Capture” system which is the same as the default roblox studio selection. What I mean is you hold down one point on your screen, drag it to a new position & let go, all the parts in that region will be selected.
I’ve created the entire system apart from how to actually get an array of parts inside of the region, my issue is the region isn’t square since the origin point is the camera & it sort of cones outward. I don’t know how to capture the parts in a region that isn’t square.
I’ve been scratching my head about this & the only thing I can think of (but don’t want to do, it’s not hard, just inefficient) is ray scanning, casting a bunch of rays inside of the region & scanning for parts it intersects.
You can model this shape by transforming parts into the camera’s CFrame and then doing a regular rectangular area check. Note that you also need to project the positions, which CFrame doesn’t do, but theres a function that can get the “screen” position from the camera and world position:
I’m using ScreenPointToRay to get 3 points in the world based off of the selection box (Top Left, Top Right & Bottom Left). I’ve created parts to be positioned in the world to visualize this (shown in the gif).
I’m not sure how I would go about transforming parts into the Frustum shape, & then getting all of the parts inside of it.