September 20, 2022


Map:RayCast(startPos, direction, distance, isThrough)


Obtain the hit information of radiographic testing. Performance worse thanMap:RayCheck()


Variable name Type Describe
startPos Vector3 Ray starting point
direction Vector3 Ray direction, default vector3 Zero
distance float Ray distance
isThrough bool Whether the ray is penetrable. The default is true

Return value

Type Describe
table<HitResult> A list of all detected hit information, each hit information contains information such as the instance of the hit, the distance of the hit, etc.

Code example

Detect the instance list of ray hits between 5 units to the right of the current scene coordinate (0,1,0) on the client

local map = World.CurMap
local startPos = Vector3.new(0,1,0)
local direction = Vector3.Right
local distance = 5
local resultList = map:RayCast(startPos, direction, distance, true)
for _, result in pairs(resultList) do