Rigidbody.SweepTest(Vector3 direction, number maxDistance = math.huge, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal)
Tests if a rigidbody would collide with anything, if it was moved through the Scene.
Parameters:
Name | Type | Description |
---|---|---|
direction | Vector3 | The direction into which to sweep the rigidbody. |
maxDistance | number | The length of the sweep. |
queryTriggerInteraction | QueryTriggerInteraction | Specifies whether this query should hit Triggers. |
Returns:
type | Description |
---|---|
boolean | True when the rigidbody sweep intersects any collider, otherwise false. |
RaycastHit | If true is returned, hitInfo will contain more information about where the collider was hit |
Usage
---@type Rigidbody
local rigidbody;
---@type Vector3
local direction;
---@type number
local maxDistance;
---@type QueryTriggerInteraction
local queryTriggerInteraction;
local val0, val1 = rigidbody.SweepTest(direction, maxDistance, queryTriggerInteraction)