Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
3

Checking for part (inside Camera) within a chosen point?

Asked by
XxSWxX 18
5 years ago

So apparently the internal function FindPartOnRay is not a valid member of Camera.

This is crucial for a project I'm working on that has everything client sided. I tried Region3, but had the same issue. Is there any possible way I can check inside the camera for a part's existence within a chosen point?

1
It isn't a method of the Camera object, it's a method of the Workspace. User#19524 175 — 5y
0
Just Use, WorldToScreenPoint Or ViewPoint YTMilky 15 — 5y

1 answer

Log in to vote
0
Answered by
YTMilky 15
5 years ago
Edited 5 years ago
local Player = game.Players.LocalPlayer
local Cam = workspace.CurrentCamera;




game:GetService('RunService').RenderStepped:Connect(function()

for a,b in pairs(workspace:GetChildren()) do
    if b:IsA('BasePart') and b.Name ~= 'NoDetect' and b ~= workspace.Baseplate then
    local Pos, InView = Cam:WorldToScreenPoint(b.Position + Vector3.new(-b.Size.x/2,- b.Size.y/2, -b.Size.z/2))--<Uses the size of the obj the properly get the position of it since originaly the position of an object is the center
        if InView then
            b.Material = Enum.Material.Neon;
            print(b.Name..' Visible')
        else
            b.Material = Enum.Material.CorrodedMetal
            print(b.Name..' Not Visible')
        end 
    end
    end
end)
0
Thanks, I got that to work! XxSWxX 18 — 5y
Ad

Answer this question