Data type
RaycastParams
A container for parameters used in raycasting operations.
About RaycastParams
The RaycastParams data type stores parameters for
WorldRoot.Raycast operations. The
ExcludeInstances and
IncludeInstances properties store a
set of objects and their descendants that will be excluded and included from
the query. The RaycastParams.IgnoreWater property can be used to
ignore Terrain water, and the RaycastParams.CollisionGroup
property can specify a collision group for the raycasting operation.
This object is different from the similarly named RaycastResult
which provides the results of a raycast.
Unlike most data types in Luau, you can change all of the members of
RaycastParams without creating a new object, allowing you to reuse
the same object repeatedly.
Constructors 1
RaycastParams.new
()Returns a blankRaycastParams.
Properties 10
ExcludeInstances
: {Instance}?An optional array of instances whose descendants will be excluded from the query.An optional array of instances whose descendants will be excluded from the query. This property can be used simultaneously with
IncludeInstancesto allow for mixed filtering, for example including a large folder but excluding specific child instances. If an instance matches both an exclude and include filter, exclusions take priority over inclusions.IncludeInstances
: {Instance}?An optional array of instances whose descendants will be included in the query.An optional array of instances whose descendants will be included in the query. This property can be used simultaneously with
ExcludeInstancesto allow for mixed filtering. If an instance matches both an exclude and include filter, exclusions take priority over inclusions.Setting
IncludeInstancestonilversus an empty array ({}) has opposite effects.IncludeInstances = nilis the most permissive filter (includes everything), whereasIncludeInstances = {}is the most restrictive filter (includes nothing).IgnoreWater
: boolDetermines whether the water material is considered when raycasting againstTerrain.CollisionGroup
: stringThe collision group used for the operation.Specifies a collision group for the raycasting operation. Parts in collision groups that are set to not collide with this group are ignored. If this property is omitted, the raycast assumes the Default collision group.
RespectCanCollide
: boolDetermines whether the raycast operation considers a part'sCanCollideproperty value over itsCanQueryvalue.This property, if
true, makes the raycast operation use an intersected part'sCanCollidevalue in favor of itsCanQueryvalue when determining whether that part is included in theRaycastResult.BruteForceAllSlow
: boolWhen enabled, the query will ignore all part collision properties and perform a brute-force check on every part.When enabled, the query will ignore all part collision properties and perform a brute-force check on every part. This will negatively impact performance and should not be used in live experiences.
Margin
: numberExpands the cast shape uniformly in every direction.Expands the cast shape uniformly in every direction. Must be finite and greater than or equal to
0. Defaults to0.Marginapplies toWorldRoot.Shapecast,WorldRoot.Blockcast,WorldRoot.SpherecastandWorldRoot.Raycast. The expanded shape is what the maximum-size limit is checked against, so a largeMargincan make an otherwise valid cast throw.Setting a non-zero
Marginon aWorldRoot.Raycastmakes the operation behave as a sphere cast of that radius.SizeGradient
: numberScales the cast shape over the length of the cast, tapering the swept volume.Scales the cast shape over the length of the cast. Must be finite and greater than or equal to
-1. Defaults to0, which casts the shape at a constant size.The shape starts at its original size and is scaled by
1 + SizeGradientby the end of the cast, interpolating in between. ASizeGradientof0.5finishes the cast 50% larger,-0.5finishes it at half size, and-1shrinks it away entirely.SizeGradientscales the shape's own size, notMargin, so a cast with both keeps its margin at a constant width along the way.WorldRoot.Spherecastis the exception: radius and margin are one and the same for a sphere, so both scale together.FilterDescendantsInstances
: ArrayAn array of objects whose descendants are used to filter raycasting candidates.An array of objects whose descendants are used to filter raycasting candidates. Note that this property has been superseded by
ExcludeInstancesandIncludeInstanceswhich should be used for new work.FilterType
: RaycastFilterTypeDetermines whether theFilterDescendantsInstancesarray is used as an exclude or include list.Determines whether the
FilterDescendantsInstancesarray is used as an exclude or include list. Note that this property has been superseded byExcludeInstancesandIncludeInstanceswhich should be used for new work.
Methods 1
AddToFilter
(instances: Instance | Array) → ()Adds the instances provided toFilterDescendantsInstances.Adds the instances provided to
FilterDescendantsInstances. Note that this property has been superseded byExcludeInstancesandIncludeInstanceswhich should be used for new work.
Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.