RaycastBool

Constructor:

RaycastBool(origin,direction,maxDistance)

Description

Creates a ray using the specified start point and direction, and returns a Bool value, indicating whether the ray hits an object or not.

Parameters

Name Type Description
origin Vector3 Starting point
direction Vector3 Direction
maxDistance float Maximum distance

Return Value

Type Description
bool It hits or not

Examples

Continuously emit rays from the starting point (0,0,0) along the direction of Vector3(0,0,-10). Observe whether the rays hit the object or not.

local function MyUpdate()
    local origin = Vector3.New(0,0,0)
    local direction = Vector3(0,0,-10)
    local maxDistance = 10
    local bool = WorkSpace:RaycastBool(origin,direction,maxDistance)    
    print("RaycastBool ============"..tostring(bool))
end
    
local function coroutineUpdate()
    while true do
        coroutine.wait(0.1)
        MyUpdate()
    end
end

coroutine.start(coroutineUpdate)