Physics.BoxCast(PhysicBox physicBox)
Casts the box along a ray and returns detailed information on what was hit.
Parameters:
Name | Type | Description |
---|---|---|
physicBox | PhysicBox | Physic Box to cast. |
Returns:
type | Description |
---|---|
boolean | True, if any intersections were found. |
RaycastHit | If 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