Skip to main content

Ray

Raycasting made easier using a custom class.

Package Attribute Value
__singleton false
__domain shared

Types

Ray

type Ray = Ray

To set any of the RaycastParams, access it directly from the object and set the value.

local ray = Ray.new(...)

-- Ignore Terrain water
ray.IgnoreWater = true

Properties

Direction

Ray.Direction: Vector3

Access the Vector3 direction of the ray.

Origin

Ray.Origin: Vector3

Access the Vector3 origin of the ray.

Functions

new

instantiater
Ray.new(
originVector3,
directionVector3
) → Ray

Create a new Ray object using origin and direction.

Cast

Ray:Cast() → RaycastResult

Equivalent to workspace:Raycast().

CastExclude

Ray:CastExclude(exclude{Instance}) → RaycastResult

Sets the filter type to Exclude and applies the filter, then executes Ray.Cast.

Visualize

Ray:Visualize(args{
colorColor3?,
decaynumber?
}) → ()

Creates a new part to visualize the ray. By default, color is a random Color3 value and decay is 7 seconds.

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "Create a new [Ray] object using `origin` and `direction`.",
            "params": [
                {
                    "name": "origin",
                    "desc": "",
                    "lua_type": "Vector3"
                },
                {
                    "name": "direction",
                    "desc": "",
                    "lua_type": "Vector3"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Ray"
                }
            ],
            "function_type": "static",
            "tags": [
                "instantiater"
            ],
            "source": {
                "line": 33,
                "path": "src/essentials/Ray.lua"
            }
        },
        {
            "name": "Cast",
            "desc": "Equivalent to workspace:Raycast().",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "RaycastResult"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 46,
                "path": "src/essentials/Ray.lua"
            }
        },
        {
            "name": "CastExclude",
            "desc": "Sets the filter type to `Exclude` and applies the filter, then executes [Ray.Cast].",
            "params": [
                {
                    "name": "exclude",
                    "desc": "",
                    "lua_type": "{ Instance }"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "RaycastResult"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 56,
                "path": "src/essentials/Ray.lua"
            }
        },
        {
            "name": "Visualize",
            "desc": "Creates a new part to visualize the ray. By default, `color` is a random [Color3] value and `decay` is 7 seconds.",
            "params": [
                {
                    "name": "args",
                    "desc": "",
                    "lua_type": "{color: Color3?, decay: number?}"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 67,
                "path": "src/essentials/Ray.lua"
            }
        }
    ],
    "properties": [
        {
            "name": "Direction",
            "desc": "Access the Vector3 direction of the ray.",
            "lua_type": "Vector3",
            "source": {
                "line": 108,
                "path": "src/essentials/Ray.lua"
            }
        },
        {
            "name": "Origin",
            "desc": "Access the Vector3 origin of the ray.",
            "lua_type": "Vector3",
            "source": {
                "line": 115,
                "path": "src/essentials/Ray.lua"
            }
        }
    ],
    "types": [
        {
            "name": "Ray",
            "desc": "To set any of the `RaycastParams`, access it directly from the object and set the value.\n\n```lua\nlocal ray = Ray.new(...)\n\n-- Ignore Terrain water\nray.IgnoreWater = true\n```",
            "lua_type": "Ray",
            "source": {
                "line": 129,
                "path": "src/essentials/Ray.lua"
            }
        }
    ],
    "name": "Ray",
    "desc": "Raycasting made easier using a custom class.\n\n| Package Attribute | Value |\n| --- | --- |\n| __singleton | false |\n| __domain | shared |",
    "source": {
        "line": 102,
        "path": "src/essentials/Ray.lua"
    }
}