Physics.SphereCast(PhysicSphere physicSphere)
Casts a sphere along a ray and returns detailed information on what was hit.
Parameters:
Name | Type | Description |
---|---|---|
physicSphere | PhysicSphere | The PhysicSphere to cast. |
Returns:
type | Description |
---|---|
boolean | True when the sphere sweep intersects any collider, otherwise false. |
RaycastHit | hitInfo contain more information about where the collider was hit. |
Usage
---@type PhysicSphere
local physicSphere;
local val0, val1 = Physics:SphereCast(physicSphere)
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 sphere cast");
local center = TestRayCasting.gameObject.transform.position;
local hit, castInfo = Physics:SphereCast(PhysicSphere(center, 10, Vector3.forward));
if (hit) then
Debug.Log("Cast succesful");
Debug.Log("Cast dist: " .. tostring(castInfo.distance));
end
end
end