So we all know that we can raycast effectively as long as the parts/objects are a child of workspace, after all, it’s a workspace function.
But now with the added feature of ViewportFrames, there’s a new environment where visibly rendered parts exist. So far I haven’t found a way to use raycasting, region3’s or any kind of collision detection inside viewport frames, which is very important since I don’t want to have to have a copy of the viewport’s contents somewhere else just so I can raycast…
Is there a way to manually raycast? or is there a way to raycast and detect objects that are not descendants of workspace…
I’m pretty sure that the only relevance Workspace has to any of the Ray methods or the Ray constructor is that it’s where the methods are stored. Have you attempted to use the Raycast methods anyway within a ViewportFrame? I don’t assume it’d error.
That being said, I haven’t tried it myself and I don’t see anything that states the raycast methods can only be used within the Workspace.
You are still able to use the Ray constructor, no? It’s just that physics aren’t run in ViewportFrames and thus the methods can’t be used.
Sounds like a workaround would have to be done, such as cloning the contents of the ViewportFrame to the workspace and then performing physics functions there, then translating that to the ViewportFrame.
The Ray constructor just takes vectors, it doesn’t know where your parts are. The issue is that parts in the viewportframe (assuming the vpf is not itself in workspace obviously) are not in the workspace, therefore not in the physics system’s octree, and therefore not able to be hit by rays.