# RaycastParams

## Overview

RaycastParams is a configuration data type that defines the conditions and filters to be applied when executing a Raycast. It is used when calling WorldRoot:Raycast and allows fine control over which objects to be included or excluded from collision targets and which collision group criteria to use for testing.

## Constructors

### new

Creates a new RaycastParams instance. No initial configuration values are included at creation, and properties such as filters and collision groups to be used for raycasting must be specified individually according to the intended use.

#### Parameters

#### Return

| `RaycastParams` | The created RaycastParams. |
| --------------- | -------------------------- |

#### Code Samples

```lua
local RaycastParams = RaycastParams.new()
```

## Properties

### BruteForceAllSlow

`boolean`

Currently not supported.

#### Code Samples

### CollisionGroup

`string`

Defines which collision group rules the raycast will operate based on. Specified collision groups and parts that are mutual collision is not allowed are automatically excluded from raycast targets. If not configured separately, the default collision group is used to process the raycast.

#### Code Samples

```lua
local RaycastParams = RaycastParams.new()
RaycastParams.CollisionGroup = "MyCollisionGroup"
```

### FilterDescendantsInstances

`Array`

This array specifies the reference objects to be included or excluded when performing raycast. All child elements of each object registered in the array are considered together, and depending on the FilterType setting, they are either included in or ignored as raycast collision targets.

#### Code Samples

```lua
local RaycastParams = RaycastParams.new()
RaycastParams.FilterDescendantsInstances =
{
    Workspace.Part1,
    Workspace.Part2
}
```

### FilterType

`Enum.RaycastFilterType`

Specifies whether objects included in FilterDescendantsInstances should be included in or excluded from raycast targets. Depending on the selected RaycastFilterType enum value, the array is applied as a criterion to limit collision check candidates.

#### Code Samples

```lua
local RaycastParams = RaycastParams.new()
RaycastParams.FilterType = Enum.RaycastFilterType.Exclude
```

### FindInitialOverlaps

`boolean`

Sets whether objects that are already overlapping at the start of the raycast should also be included in the results.

#### Code Samples

### IgnoreWater

`boolean`

Currently not supported.

#### Code Samples

### RespectCanCollide

`boolean`

Currently not supported.

#### Code Samples

### TraceComplex

`boolean`

Sets whether to perform a precise raycast using complex collision meshes.

#### Code Samples

## Methods

### AddToFilter

Adds the specified instances to the FilterDescendantsInstances list.

This is simpler and more efficient than directly modifying the filter array, allowing safer and more consistent management of raycast filter configuration. This method is also suitable for incrementally accumulating filter settings.

#### Parameters

| `Value` InValue | The instance or array of instances to be added to the raycast filter. |
| --------------- | --------------------------------------------------------------------- |

#### Return

| `RaycastParams` | Returns the RaycastParams object with the updated filter. |
| --------------- | --------------------------------------------------------- |

#### Code Samples

```lua
local RaycastParams = RaycastParams.new()
RaycastParams:AddToFilter(Workspace.Part1)
RaycastParams:AddToFilter({ Workspace.Part2, Workspace.Part3 })
```

## Events

## See also

{% content-ref url="/pages/A9RxgYKTmNNgDRmjtQwe" %}
[WorldRoot](/development/api-reference/classes/worldroot.md)
{% endcontent-ref %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.overdare.com/development/api-reference/datatype/raycastparams.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
