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.
Constructors
new
Creates a new RaycastParams object with default values.
Parameters
Return
RaycastParams
A new RaycastParams.
Code Samples
local RaycastParams = RaycastParams.new()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.Exclude 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 = trueCollisionGroup
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 = trueBruteForceAllSlow
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 = falseMethods
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)
RaycastParams:AddToFilter({ Workspace.Part2, Workspace.Part3 })Last updated