Camera:GetPartsObscuringTarget

Instances

This method returns an array of BaseParts that are obscuring the lines of sight between the camera's CFrame and Vector3 positions in the castPoints array. Any Instances included in the ignoreList array will be ignored, along with their descendants.

The castPoints parameter is given as an array of Vector3 positions. Note that the array of BaseParts returned is in an arbitrary order, and no additional raycast data is provided. If you need data such as hit position, hit material, or surface normal, you should opt for the WorldRoot:Raycast() method.


local Workspace = game:GetService("Workspace")
local camera = Workspace.CurrentCamera
local castPoints = {
Vector3.new(0, 10, 0),
Vector3.new(0, 15, 0)
}
local ignoreList = {}
local partsObscuringTarget = camera:GetPartsObscuringTarget(castPoints, ignoreList)

If Terrain obscures a cast point, BaseParts obscuring the cast point between the obscuring Terrain and the cast point will not be returned.

Parameters

castPoints: Array

An array of Vector3 positions of cast points.

Default Value: ""
ignoreList: Instances

An array of Instances that should be ignored, along with their descendants.

Default Value: ""

Returns

Instances

An array of BaseParts that obscure the lines of sight between the camera's CFrame and the castPoints.