How to make WorldToScreenPoint have ignore list

I just wanna get ignore list in there so anything on screen not in the list will print false as it will block players view

Can you give us some more info? WorldToScreenPoint just translate a 3D world position to the 2D position on screen. It doesn’t involve any instances in the actual game. Are you doing any raycasting to grab the 3D world position first?

3 Likes

I’m raycasting from players camera

local _, withinScreenBounds = camera:WorldToScreenPoint(Part.Position)

If you just want to see if a part is obscured or not, you can use Camera:GetPartsObscuringTarget.

local castPoints = {Part.Position}
local ignoreList = {Part}
local obscuringParts = camera:GetPartsObscuringTarget(castPoints, ignoreList)

if #obscuringParts == 0 then
   -- Not obscured
else
   -- Obscured
end

You could combine that with the withinScreenBound variable you have to check for your certain conditions: if withinScreenBounds and #obscuringParts == 0 then ... end

1 Like