FindObjOnRayWithIgnoreList

Constructor:

FindObjOnRayWithIgnoreList(ray,ignoreTable)

Description

The variant of FindPartOnRay, returning the objects that the ray hits and the end point, ignoring the objects in the input table.

Parameter

Name Class Name Description
ray Ray Ray
ignoreTable table Objects to ignore

Return Value

Class Name Description
RWObject Object that the ray hits.
Vector3 Position of the ray collision point.
Vector3 A normal to the touch surface through the ray collision point

Examples

Create Part1 and Part2 in the WorkSpace, and adjust their sizes for ray detection. The script is to continuously emit rays from the camera to the mouse position. When the rays hit an object, the object changes color. Observe whether the printed return value is correct or not.

local function MyUpdate()
    local ray = WorkSpace. Camera: ScreenToRay(Mouse.MousePosition)
    local mt = {WorkSpace. Part1, WorkSpace. NewBackground} -- Part2 and the new background in the WorkSpace
    local e,p = WorkSpace:FindObjOnRayWithIgnoreList(ray,mt)
    if e then
        e.Color = Vector3.New(255,0,0)
        print(tostring(e.Name))
        print(tostring(p))
    end
end
    
local function coroutineUpdate()
    while true do
        coroutine.wait(0.1)
        MyUpdate()
    end
end

coroutine.start(coroutineUpdate)