SphereCast||doc136437

September 20, 2022

Format

Map:SphereCast(center, radius)

Describe

Get the hit information of ball type detection. Better performance thanMap:SphereCheck()

parameter

Variable name Type Describe
center Vector3 Spherical center point
radius float Spherical radius

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 current scene coordinates (0,0,0) on the client, and a list of instances of ball detection hits per unit volume

local map = World.CurMap
local center = Vector3.new(0,0,0)
local radius = 0.5
local resultList = map:SphereCast(center, radius)
for _, result in pairs(resultList) do
    print(result.Instance)
end