RaycastParams

Overview

Description

The RaycastParams object is used to configure the behavior and filtering of raycasting functions in Lua. It allows developers to specify options such as ignoring specific objects, setting collision groups, and filtering based on custom rules.

Properties

FilterDescendantsInstances

array Defines a list of instances whose descendants should be ignored or included by the raycast, depending on the FilterType property.

Code Samples

local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {workspace.Part1, workspace.Part2}

FilterType

Enum.RaycastFilterType Specifies whether the instances in FilterDescendantsInstances should be included or excluded. Valid values are Whitelist or Blacklist.

Code Samples

local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist

IgnoreWater

boolean Determines whether the raycast should ignore water. If set to true, water will not block or interact with the ray.

Code Samples

local raycastParams = RaycastParams.new()
raycastParams.IgnoreWater = true

CollisionGroup

string Specifies the collision group for the raycast. This allows filtering based on predefined collision group rules.

Code Samples

local raycastParams = RaycastParams.new()
raycastParams.CollisionGroup = "MyCollisionGroup"

RespectCanCollide

boolean Indicates whether the raycast should respect the CanCollide property of objects. If false, non-collidable objects can still interact with the ray.

Code Samples

local raycastParams = RaycastParams.new()
raycastParams.RespectCanCollide = true

BruteForceAllSlow

boolean If set to true, all objects in the workspace will be checked during the raycast, which can be computationally expensive. This is generally used for debugging or exhaustive collision checks.

Code Samples

local raycastParams = RaycastParams.new()
raycastParams.BruteForceAllSlow = false

Constructors

new

Creates a new RaycastParams object with default values.

Parameters

Return

RaycastParams

A new RaycastParams.

Code Samples

local raycastParams = RaycastParams.new()

Methods

AddToFilter

Adds one or more instances to the FilterDescendantsInstances property.

Parameters

Instance|array InValue

The instance(s) to add to the filter.

Return

RaycastParams

Returns the updated `RaycastParams` object.

Code Samples

local raycastParams = RaycastParams.new()
raycastParams:AddToFilter(workspace.Part1)

local raycastParams2 = RaycastParams.new()
raycastParams2:AddToFilter({workspace.Part1, workspace.Part2})

Last updated