Skip to main content

Physics.BoxCast(PhysicBox physicBox)

Casts the box along a ray and returns detailed information on what was hit.

Parameters:

NameTypeDescription
physicBoxPhysicBoxPhysic Box to cast.

Returns:

typeDescription
booleanTrue, if any intersections were found.
RaycastHitIf true is returned, hitInfo will contain more information about where the collider was hit.

Usage

---@type PhysicBox
local physicBox;


local val0, val1 = Physics:BoxCast(physicBox)

Example

do -- script TestRayCasting 

-- get reference to the script
local TestRayCasting = LUA.script;

-- start only called at beginning
function TestRayCasting.Start()
Debug.Log("Making a box cast");
local center = TestRayCasting.gameObject.transform.position;
local hit, castInfo = Physics:BoxCast(PhysicBox(Vector3.zero, Vector3.one, Vector3.up));
if (hit) then
Debug.Log("Cast succesful");
Debug.Log("Cast dist: " .. tostring(castInfo.distance));
end
end
end