Physics.CapsuleCast(PhysicCapsule physicCapsule)
Casts a capsule against all colliders in the Scene and returns detailed information on what was hit.
Parameters:
Name | Type | Description |
---|---|---|
physicCapsule | PhysicCapsule | The physic capsule to cast. |
Returns:
type | Description |
---|---|
boolean | True when the capsule sweep intersects any collider, otherwise false. |
RaycastHit | If true is returned, hitInfo will contain more information about where the collider was hit. |
Usage
---@type PhysicCapsule
local physicCapsule;
local val0, val1 = Physics:CapsuleCast(physicCapsule)
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 capsule cast");
local center = TestRayCasting.gameObject.transform.position;
local hit, castInfo = Physics:CapsuleCast(PhysicCapsule(center + Vector3.right, center + Vector3.left, 5, Vector3.forward));
if (hit) then
Debug.Log("Cast succesful");
Debug.Log("Cast dist: " .. tostring(castInfo.distance));
end
end
end